dominick
Explore posts from serversCookie nginx+pm2
export default defineNuxtRouteMiddleware((to, _from) => {
const user = useStrapiUser()
const authPage = ['login', 'signup']
const noAuthPage = ['blog-slug', 'blog', 'docs-slug', 'docs', 'pricing', 'index']
if (user.value) {
if (authPage.includes(to.name.toString())) {
return navigateTo({ name: 'index' })
}
} else {
if (!(noAuthPage.includes(to.name.toString())) && !authPage.includes(to.name.toString())) {
useCookie('redirect', { path: '/' }).value = to.fullPath
return navigateTo({ name: 'login' })
}
}
})
In the development environment, after logging in, const user = useStrapiUser() has a value; however, in the production environment (using Nginx + PM2), after logging in, const user = useStrapiUser() is empty. I believe this issue is related to the cookie configuration. Here is my cookie configuration:
cookie: {
path: '/',
maxAge: 14 * 24 * 60 * 60,
secure: process.env.NODE_ENV === 'production',
sameSite: true,
domain: process.env.COOKIE_DOMAIN
},
5 replies
CDCloudflare Developers
•Created by dominick on 11/10/2024 in #general-help
Files with the type Ongoing Multipart Upload cannot be deleted
1 replies