-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth session missing! (500) causes prerendering to fail #388
Comments
I am having the same problem Here is how you can reproduce it (just need to add (SUPABASE_URL and SUPABASE_KEY to .env): https://github.com/mohamed-ali-masmoudi/supa-nuxt-500 |
+1 ... I've updated the nuxt module to the latest version (1.3.5) from 1.2.2 and now getting this error as well. Running nuxt 3.12.4. Error occurs immediately after running pnpm dev. at createError (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:78:15) |
I believe this is a possible temporary workaround.
|
@Fwosty Thanks for the workaround! The problem is that Nuxt executes the files under "/server/middleware" on every request for all the routes also for "/" where in our case the user is not logged yet. Here are two other potential workarounds: 1- Set a list for the protected routes (that should include the user)
2- Just make it non blocking by catching the error
|
I tried the second approach at some obvious places in my app where the stack traces helped but then I still get these kind of generic stack traces. Before a search for all instances of
|
anyone managed to get this working? the workarounds prevent the app from crashing but this leaves the server routes unprotected...been stuck with this for almost 2 weeks now... |
I just pinned the 1.2.2 version. |
@radum2o18, I just implemented the first approach with a protected routes list. For example, you can set all your protected routes like this (but you have to edit the folder structure): const protectedRoutes = [
"/api/protected",
] With this setup, my protected routes always require a user, and for the public ones, I don't set the user and don't get any error |
Also getting this since upgrading. It would be nice not to have to build in a workaround when nothing's supposed to be changed to warrant this. |
The workaround 1 works for me, but I have to do it on every middleware any anything that might get used while prerendering during build including server api routes. It basically makes sense to implement a helper that wraps |
Example: import { serverSupabaseUser } from "#supabase/server"
export default defineEventHandler(async (event) => {
try {
const user = await serverSupabaseUser(event);
if (!user) {
event.context.user = null;
// Handle unauthenticated case
return
}
event.context.user = user;
} catch (error) {
event.context.user = null;
// Handle unauthenticated case
}
}) Maybe |
I just updated to 1.3.1 and my app does not
npx nuxi build
anymore because of 500 errors in the prerendering.Version
@nuxtjs/supabase: v1.3.1
nuxt: 3.12.3
Steps to reproduce
I have a middleware
server/middleware/auth.ts
(shortened) and use the composables in various pages, components and composables. Before version v.1.3.0 and switching new library in #357 this did not happen.Error in v.1.3.1
The text was updated successfully, but these errors were encountered: