-
-
Notifications
You must be signed in to change notification settings - Fork 17.2k
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
res.locals value not available in template engine #5081
Comments
Hi, after mimicking your situation I was able to reproduce it. Although not quite sure why its happening, though you can try the below as a work around if you like: In your routes file:
PS: Do remember it will run for all the routes below itself |
Express 5.0 has a different path matching syntax than Express 4. It is documented in Moving to Express 5 on the expressjs website. If you want to execute middleware for all paths, use @mhamzabcs' suggestion and skip the path argument in
Related issues and PRs: #2057, #4321, pillarjs/router#42 |
Awesome, that works. Thank you @mhamzabcs and @krzysdz. |
Hey, I have this middleware in app.js
within isUserLoggedInMiddleware.js I have
in my navigation.hbs template file I have
prior to to upgrading to express@>=5.0.0-beta.1, once a user logged in, the navigation would only show the
Log out
option, but after upgrading, it still shows theLog in
andSign up
options when a user is logged in.I tried to see if I could access the user on
res.locals.user = user
within the template engine, and it seems like it's not avaialble within it.The text was updated successfully, but these errors were encountered: