trips) adding initial commit
This commit is contained in:
15
src/hooks.server.ts
Normal file
15
src/hooks.server.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { handle as authHandle } from './auth.js';
|
||||
import { sequence } from '@sveltejs/kit/hooks';
|
||||
import type { Handle } from '@sveltejs/kit';
|
||||
|
||||
// When behind a reverse proxy that terminates SSL, rewrite the request URL
|
||||
// to use https so that SvelteKit generates correct absolute URLs and form actions.
|
||||
const httpsProxy: Handle = async ({ event, resolve }) => {
|
||||
const proto = event.request.headers.get('x-forwarded-proto');
|
||||
if (proto === 'https' && event.url.protocol === 'http:') {
|
||||
event.url.protocol = 'https:';
|
||||
}
|
||||
return resolve(event);
|
||||
};
|
||||
|
||||
export const handle = sequence(httpsProxy, authHandle);
|
||||
Reference in New Issue
Block a user