diff options
Diffstat (limited to 'frontend/src/hooks.server.js')
| -rw-r--r-- | frontend/src/hooks.server.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/frontend/src/hooks.server.js b/frontend/src/hooks.server.js index 39c89e9..0c53a3d 100644 --- a/frontend/src/hooks.server.js +++ b/frontend/src/hooks.server.js @@ -1,7 +1,8 @@ import { redirect } from '@sveltejs/kit'; -const API = 'http://localhost:8080/api'; +import { building } from '$app/environment'; +const API_BASE = building ? 'http://localhost:8080/api' : '/api'; const PUBLIC_PREFIXES = ['/_app', '/api']; export async function handle({ event, resolve }) { @@ -18,7 +19,7 @@ export async function handle({ event, resolve }) { if (!token) { throw redirect(302, '/login'); } - const res = await fetch(`${API}/auth/verify`, { + const res = await fetch(`${API_BASE}/auth/verify`, { headers: { Authorization: `Bearer ${token}` } }); if (!res.ok) { |