I am using Google login but everytime I login it disregards the internationalization that I have
c
I am using Google login but everytime I login it disregards the internationalization that I have
1. On /en/login
2. Login using Google
3. Redirect back to /home instead of /en/home
r
Which recipe are you using?
c
thirdpartyemailpassword
c
I am already doing that
Copy code
getRedirectionURL: async (context) => {
          if (context.action === 'SUCCESS') {
            if (context.redirectToPath !== undefined) {
              // we are navigating back to where the user was before they authenticated
              return context.redirectToPath;
            }
            console.log(Router.locale);
            if (Router.locale === 'en-US') {
              toast.success('Welcome back!', {
                position: toast.POSITION.BOTTOM_RIGHT,
              });
            } else if (Router.locale === 'zh') {
              toast.success('欢迎!', {
                position: toast.POSITION.BOTTOM_RIGHT,
              });
            }
            return '/home';
          }
          return undefined;
        },
If I sign up using email+password, it works
If using Google login it fails
r
Where does it come in the function with google login? Can you add console logs and see which return statement it getting executed?
c
it goes into the en-Us if-block
r
Hmmm. Might be a bug in the SDK. Can you open an issue about this? We will check it out sometime today / tomorrow
c
which repo
r
Supertokens-auth-react
r
Oh wait how does that function know which is the right locale? Based on the current URL path?
c
Yes
NextJS
r
Ah right. So with Google, the callback route is simple /auth/callback/google
That’s why it returns you to just /home
So you might want to use another way to get the locale other than the current path
For example, store that info in localstorage and read it from that
c
Is there a way to customize the google callback?
My whole app is using NextJS's router locale
r
Well, you don’t need to customise the google callback. You need to customise this function to get the right locale
c
Which function?
r
The one you have provided
The getRedirection function
c
I see
r
And then in the login page, you can save the local in localstorage. And in this function, read it from localstorage
c
Understood
Thanks!
r
Could you please close the above issue?
c
Yeap
It failed to work
When google login button is clicked on
It redirects me to the page accounts.google.com.....
r
Well yea.. but ok the login page where you show the google button, you can save to local storage
c
All the localhost localstorage data are lost
r
Localstorage data will be available after google redirects you back to your app
c
Also there is this warning: next-dev.js?3515:20 Warning: Prop
href
did not match. Server: "/auth/callback/google?
Yes but when it redirects back
the locale turns back to en
r
What about the localstorage value?
c
back to en
r
How? Where r u setting the localstorage,
c
Let me try again
Do you know why the erros is showing?
href error
r
Not sure why. Might be worth a google
c
Seems like a supertoken error
Warning: Prop
href
did not match. Server: "/auth/callback/google?....... at a at LinkComponent (webpack-internal:///./node_modules/next/dist/client/link.js:89:23) at div at div at div at LanguageDropdown (webpack-internal:///./components/Nav/LanguageDropdown.js:23:30) at li at ul at div at section at HeaderNavSmall (webpack-internal:///./components/Nav/HeaderNavSmall.js:28:28) at nav at div at div at nav at header at Header (webpack-internal:///./components/Nav/Header.js:37:62) at Layout (webpack-internal:///./components/Layout.js:13:26) at SessionAuth (webpack-internal:///./node_modules/supertokens-auth-react/lib/build/recipe/session/sessionAuth.js:191:23) at UserContextProvider (webpack-internal:///./node_modules/supertokens-auth-
react/lib/build/usercontext/index.js:81:23) at UserContextWrapper (webpack-internal:///./node_modules/supertokens-auth-react/lib/build/usercontext/userContextWrapper.js:27:15) at SessionAuthWrapper (webpack-internal:///./node_modules/supertokens-auth-react/lib/build/recipe/session/sessionAuth.js:485:34) at SuperTokensWrapper at MyApp (webpack-internal:///./pages/_app.js:57:27) at I18nProvider (webpack-internal:///./node_modules/next-translate/lib/esm/I18nProvider.js:31:18) at AppWithTranslations (webpack-internal:///./node_modules/next-translate/lib/esm/appWithI18n.js:68:152) at ErrorBoundary (webpack-internal:///./node_modules/next/dist/compiled/@next/react-dev-overlay/dist/client.js:8:20742) at ReactDevOverlay (webpack-internal:///./node_modules/next/dist/compiled/@next/react-dev-overlay/dist/client.js:8:23635) at Container (webpack-internal:///./node_modules/next/dist/client/index.js:70:9) at AppContainer (webpack-internal:///./node_modules/next/dist/client/index.js:240:26) at Root (webpack-internal:///./node_modules/next/dist/client/index.js:431:27) See more info here: https://nextjs.org/docs/messages/react-hydration-error
In SessionAuth?
r
im not sure.
c
No error in production tho
weird
r
well, this is just a warning
not an error
c
Yeap
warning i meant
r
seems more like a routing issue