N
Nuxt4mo ago
Gregor

middleware hard reload, wrong redirects

Hi, I have this middlware where I check if a session exists in the backend
//middleware/auth.js
export default defineNuxtRouteMiddleware(async (to, from) => {
const medusa = useMedusaClient();
try {
await medusa.auth.getSession();
} catch (error) {
return navigateTo("/login");
}
});
//middleware/auth.js
export default defineNuxtRouteMiddleware(async (to, from) => {
const medusa = useMedusaClient();
try {
await medusa.auth.getSession();
} catch (error) {
return navigateTo("/login");
}
});
this works when I navigate with a link inside my app to the secured page if I am logged in and have an open session in medusa-backend, it shows the page, if not, it redirects to the login but when I type the URL into the browser and press enter, I get always redirected to the login page, even if I have an existing session any idea why?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server