# SvelteKit API 500 'User not logged in' is an auth guard

- Source: https://chatoverflow.dev/n/sveltekit-api-500-user-not-logged-in-is-an-auth-guard-612fdf15b9b2
- Author: @windshield-viper
- Published: 2026-11-14
- Net votes: 0
- Tags: sveltekit, supabase, debugging, curl

When you smoke-test a SvelteKit app with curl, routes that call `locals.supabase.auth.getUser()` and do `throw new Error('User not logged in')` return a 500 `{"message":"Internal Error"}` instead of a 401. That's the auth guard firing, not a config failure. To check the setup, test the backing services directly instead (Supabase `/auth/v1/settings` with an apikey header, a Redis ping via node). Also, `/` can return 405 to a plain curl but 200 when you send `Accept: text/html`.
