Hi, I'm trying to implement supertokens into my ne...
# support-questions
h
Hi, I'm trying to implement supertokens into my nestjs + nextjs application with ThirdPartyEmailPassword. I encountered an error when trying to signin/signup with Google. The account is successfully signup/signin in the development environment but the /signinup api failed with status code 500 on frontend 400 on backend, then the error got displayed on the form. When reload the frontend application, it does recognize that I've logged in and redirect to the home page tho.
r
hey @howard can you please enable debug logging and show the logs on app start + when you make the API call that behaves weirdly.
h
here is the debug log.
r
thanks.
What's the config you have provided for google in the provider's list?
h
here is my supertokens.service.ts
I've tried the demo clientId and secret too but it didn't help
r
hmm this seems about fine
So for some reason, google is returning a 400 status code when supertokens is querying it with the auth code
h
yeah, I see that it still work afterwards. Can I skip the /signinup api call?
the email password works fine too
r
You can't skip it. Can you try this:
Copy code
let google = ThirdpartyEmailPassword.Google({...});

providers: [
                {
                    ...google,
                    get: function (redirectURI: string | undefined, authCodeFromRequest: string | undefined, userContext: any) {
                        const getResult = google.get(redirectURI, authCodeFromRequest, userContext);
                        return {
                            ...getResult,
                            getProfileInfo: async function (authCodeResponse: any, userContext: any) {
                                try {
                                    const result = await getResult.getProfileInfo(authCodeResponse, userContext);
                                    console.log(result); //<- this one has my login details (id, email, verified)
                                    return result;
                                } catch (err) {
                                    console.log(err);
                                    throw err;
                                }
                            }
                        };
                    }
                },
            ],
for the providers array
hmm. So it does get the result.
The issue is that it calls the API twice from the frontend
Are you running in react strict mode?
h
yeah, I am
r
Ah yea.. so in nextjs, weirdly, they call
useEffect
twice in development mode when react strict mode is enabled
h
oh, the first signinup request is not the POSR request
r
so it's calling the API twice
h
it got canceled and only contains the headers
r
Can you try to run this in a production build or without react strict mode?
It should work then
h
ok, I'll try it in the morning. Now it's 1 am in my place tho
r
ah alright!
h
thank you, I'll notice you later if there's a problem
r
do lmk if it solves the issue
h
The production build worked!
r
Yea! I opened an issue about this in nextjs: https://github.com/vercel/next.js/issues/36233
h
thank you! hope it will be resolved soon
r
yup! me too.. i was surprised that this wasn't an open issue already.. very strange
6 Views