import type { Handle } from '@sveltejs/kit'; export const handle: Handle = async ({ event, resolve }) => { // Correct origin behind Nginx const host = event.request.headers.get('x-forwarded-host') ?? event.request.headers.get('host'); const proto = event.request.headers.get('x-forwarded-proto') ?? 'https'; const origin = `${proto}://${host}`; // Example: force HTTPS (optional, Nginx should already do this) if (proto === 'http') { return new Response(null, { status: 308, headers: { Location: origin + event.url.pathname + event.url.search } }); } // Proceed with default behavior return resolve(event); };