Skip to content

Commit d0b6e9e

Browse files
author
wec
committed
check origin fix
1 parent 2e6cf56 commit d0b6e9e

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

src/routes/+layout.server.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import type { LayoutServerLoad } from './$types';
22
import { env } from '$env/dynamic/private';
33

4-
export const load: LayoutServerLoad = async ({ locals, url }) => {
5-
const origin = env.ORIGIN ?? '';
4+
export const load: LayoutServerLoad = async ({ locals }) => {
65
return {
7-
originWarning: {
8-
currentOrigin: url.origin,
9-
isWarning: origin !== url.origin
10-
},
6+
envOrigin: env.ORIGIN ?? '',
117
userAuthenticated: locals.userAuthenticated
128
};
139
};

src/routes/+layout.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<script lang="ts">
22
import { Toaster } from 'svelte-5-french-toast';
3+
import { page } from '$app/state';
34
import '../app.css';
45
let { children, data } = $props();
56
</script>
67

78
<Toaster />
8-
{#if data.originWarning.isWarning}
9+
{#if data.envOrigin !== page.url.origin}
910
<div class="w-full bg-red-600 p-2 text-center text-white">
1011
<p>
11-
Invalid origin found. Please specify ORIGIN={data.originWarning.currentOrigin}. Check
12+
Invalid ORIGIN found. Please specify ORIGIN={page.url.origin}. Check the
1213
<a
1314
target="_blank"
1415
class="underline"

0 commit comments

Comments
 (0)