-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
setNotFoundHandler does not include session variable in request object #1039
Comments
Thanks for reporting! Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that. |
@mcollina I'm using Fastify Secure Session with Google OAuth, can you tell me how to include it in a demo without Google OAuth handling the logins? If there's no quick demo of that I will look at Secure Session docs and try to come up with a limited use of it to replicate the conditions. |
If it's not related to google, use another provider. The likely outcome is that there is an issue in how you encapsulated your plugins. |
No, I was able to reproduce it with just a regular old login: |
You are using Your repro shows that the The fix would be as simple as place it inside your other plugin. |
I appreciate the extra information @climba03003 I was told to place static outside to prevent the session being read for every static file which I don't want. I tried setting |
You should provide more context on how you structure your application. |
💬 Question here
Normally all request objects include the session variables if a user is logged in. However
setNotFoundHandler
does not making my display, which normally shows the user's avatar if logged in or a login button if not, always show the login button. How do I get the session variables when usingsetNotFoundHandler
or is there an alternative approach to catch all invalid routes that will return session variables?In this case
console.log({ pageInfoUser: request.user })
returnsundefined
even when logged in whereas every other route displays theuser
session variable when logged in.Your Environment
The text was updated successfully, but these errors were encountered: