Nisthar
Explore posts from serversHow to pass data from plugins to server api endpoint in nuxt 3?
I have a module in my nuxt app. It uses a plugin to auto refresh tokens if its expired (both on client side and on server load). I need to extend this and after refreshing tokens, fetch the user data and pass it to the app's server api endpoints. How do i do that?
I have tried adding middleware into the module. It seems like middlewares are good solution but it runs before the plugin. so it doesn't get the refreshed token to fetch the user.
Does anyone have a solution to this issue?
20 replies
Does plugins run after server middlewares?
I have a module plugin like
plugin.ts
:
The plugin checks if the token is expired and refreshes it on the SSR. I am trying to get the refreshed token in the server middleware so i can fetch the currently logged in user in the server. But it seems like the server middlewares are run first before the plugin ever runs.
I need to use plugin to make the SSR auth work.
How do i get the refreshed token in the middleware so i can fetch for the user?5 replies
why isn't input's value not updating when using useState value in it?
guys i have a useState that doesn't have any values, it later gets set to an object after a fetch request to an api
But if i use this useState object's value for an input, the input value is always empty
const user = useUser()
anyone know why the input's value never changes when the useState changes?18 replies
Uncaught SyntaxError: The requested module '/_nuxt/middleware/auth.global.ts' when restarting nuxt
I get this error in the browser console everytime i restart the nuxt server. when this happens the dev tools doesn't work and hmr also doesn't work.
This is my middleware
middleware/auth.global.ts
I comment the middleware and uncomment it again to fix the error. But if i restart the server or change .env file, it happens again.2 replies
How to use layouts (using named slots)?
I want to use the dashboard-default.vue layout inside all the dashboard pages.
In the dashboard-default.vue, there's 2 named slots for header and content.
How do i use these slots inside the dashboard pages?
I tried this pages/dashboard.vue
and inside the pages/dashboard/index.vue:
This is
pages/dashboard.vue
page:
118 replies