prepare for being available on multiple domain names
This commit is contained in:
@ -7,9 +7,10 @@ const { DEV } = import.meta.env;
|
||||
|
||||
const logger = new Logger('SpotifyAuth');
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
export const load: PageServerLoad = async ({ url, request }) => {
|
||||
const baseUrl = request.headers.get('X-Forwarded-Host') ?? BASE_URL;
|
||||
const adder = new SpotifyPlaylistAdder();
|
||||
let redirect_uri = new URL(`${BASE_URL}/spotifyAuth`);
|
||||
let redirect_uri = new URL(`${new URL(BASE_URL).protocol}//${baseUrl}/spotifyAuth`);
|
||||
if (url.hostname === 'localhost' && DEV) {
|
||||
redirect_uri.hostname = '127.0.0.1';
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ import type { PageServerLoad } from './$types';
|
||||
|
||||
const logger = new Logger('YT Auth');
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
export const load: PageServerLoad = async ({ url, request }) => {
|
||||
const baseUrl = request.headers.get('X-Forwarded-Host') ?? BASE_URL;
|
||||
const adder = new YoutubePlaylistAdder();
|
||||
const redirect_uri = new URL(`${BASE_URL}/ytauth`);
|
||||
logger.debug('redirect URL', `${new URL(BASE_URL).protocol}//${baseUrl}/ytauth`);
|
||||
const redirect_uri = new URL(`${new URL(BASE_URL).protocol}//${baseUrl}/ytauth`);
|
||||
if (url.searchParams.has('code')) {
|
||||
logger.debug(url.searchParams);
|
||||
await adder.receivedAuthCode(url.searchParams.get('code') || '', redirect_uri);
|
||||
|
Reference in New Issue
Block a user