You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a system to protect a bunch of routes at once by (regex path matching + auth). This happens in my +layout.server.ts file as it will be called on every page. But when I throw an error there (like HTTP 403), my custom error page +error.svelte isn't called at all, the error is being rendered with the default SvelteKit error page, just displaying the status code and the status message.
Is there some way to throw an error in +layout.server.ts or something that works for every single page so the error will be rendered with +error.svelte instead? I also want my navbar from +layout.svelte to appear.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I created a system to protect a bunch of routes at once by (regex path matching + auth). This happens in my
+layout.server.ts
file as it will be called on every page. But when I throw an error there (like HTTP 403), my custom error page+error.svelte
isn't called at all, the error is being rendered with the default SvelteKit error page, just displaying the status code and the status message.Is there some way to throw an error in
+layout.server.ts
or something that works for every single page so the error will be rendered with+error.svelte
instead? I also want my navbar from+layout.svelte
to appear.My code:
src/routes/+layout.server.ts
src/routes/+error.svelte
Beta Was this translation helpful? Give feedback.
All reactions