Update hooks
Some checks are pending
Deploy / deploy (push) Waiting to run

This commit is contained in:
Leonardo Murça 2025-06-05 07:30:21 -03:00
parent 835aa9aea2
commit cf231feb8e

21
hooks.server.ts Normal file
View file

@ -0,0 +1,21 @@
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);
};