We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have two projects using nextjs that I would like to share authcooke, deployed in vercel.
One domain is https://example.art/ and one is https://sub.example.art/.
When https://example.art/ logs in,
https://sub.example.art/ can see the session, but as soon as https://sub.example.art/ is refreshed, the https://example.art/ login status disappears
The configuration of the two projects is basically the same, this is the next.config.js
next.config.js
cookies: { domain: '.example.art', }, async headers() { if (process.env.NODE_ENV == 'production') return [ { source: '/api/auth/:path*', has: [{ type: 'header', key: 'Origin', value: '(?<serviceName>^https://.*.example.art$)' }], headers: [ { key: 'Access-Control-Allow-Credentials', value: 'true' }, { key: 'Access-Control-Allow-Origin', value: ':origin' }, { key: 'Access-Control-Allow-Methods', value: 'GET, OPTIONS, PATCH, DELETE, POST, PUT' }, { key: 'Access-Control-Allow-Headers', value: 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version', }, ], }, ] },
[...nextauth.ts]
export const authOptions: NextAuthOptions = { adapter: MongoDBAdapter(clientPromise, { databaseName: process.env.MONGODB_NAME }), providers: (() => { const final: (OAuthConfig<any> | EmailConfig)[] = [ GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, authorization: { params: { prompt: 'consent', access_type: 'offline', response_type: 'code', }, }, httpOptions: { timeout: 10000, }, profile(profile) { return { ...profile, role: AuthRole.USER, avatar: profile.picture, id: profile.sub } }, }), ] return final })(), session: { strategy: 'database' }, cookies: { sessionToken: { name: `${useSecureCookies ? '__Secure-' : ''}next-auth.session-token`, options: { httpOnly: true, sameSite: 'lax', path: '/', domain: useSecureCookies ? '.replicable.art' : undefined, secure: useSecureCookies, }, }, }, }
I don't know what the problem is and how I should change it
Details as above
Yes, I am willing to help answer this question in a PR
The text was updated successfully, but these errors were encountered:
Hey @faye1225. I'm wondering how you solved this? Having the same doubt.
Sorry, something went wrong.
No branches or pull requests
Question 💬
I have two projects using nextjs that I would like to share authcooke, deployed in vercel.
One domain is https://example.art/ and one is https://sub.example.art/.
When https://example.art/ logs in,
https://sub.example.art/ can see the session, but as soon as https://sub.example.art/ is refreshed, the https://example.art/ login status disappears
The configuration of the two projects is basically the same, this is the
next.config.js
[...nextauth.ts]
I don't know what the problem is and how I should change it
How to reproduce ☕️
Details as above
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
The text was updated successfully, but these errors were encountered: