Skip to content

Conversation

@ivan-kadyka
Copy link

@ivan-kadyka ivan-kadyka commented Jun 14, 2025

First of all, @QuiiBz, thank you for your great library!

Problem:
executing server function 'getCurrentLocale' can cause error: '[next-international] Locale not found in headers or cookies, returning "notFound()"'

Description:
When users authenticate via OAuth (Google provider), the callback redirect from Google's servers to our application doesn't include the locale cookie due to the sameSite: 'strict' setting. This results in getCurrentLocale() returning undefined during the authentication callback.

OAuth redirects:

  1. 'your-website.com'
  2. 'oauth-website.com '
  3. 'your-website.com'

My use case:
Google OAuth with 'next-auth' library and 'events' configuration

  export const authOptions: AuthOptions = {
  adapter: PrismaAdapter(prisma),
  providers: [
    Google({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET
    })],
  events: {
    async signIn({ user }) {
       
    const locale = await getCurrentLocale()
    // locale is undefined
    // '[next-international] Locale not found in headers or cookies, returning "notFound()"' 
    // google auth url:  https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount

    // sending analytics how locale information is used
     
    }}
    ...
  }

Solution:
Storing information about the user's selected locale is not strictly secure. Change the locale cookie setting to use the browser default (sameSite: 'lax').

@vercel
Copy link

vercel bot commented Jun 14, 2025

@ivan-kadyka is attempting to deploy a commit to the Tom Labs Team on Vercel.

A member of the Team first needs to authorize it.

@dnil-hcom
Copy link

This is also an issue with link scanners that are built into outlook, teams etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants