prepare for being available on multiple domain names

This commit is contained in:
2025-07-06 18:43:36 +02:00
parent 260cef7b73
commit 38e8b4c2ba
8 changed files with 97 additions and 25 deletions

View File

@ -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';
}