#Hey there

1 messages · Page 1 of 1 (latest)

subtle flume
#

This is what I see after signing in:

No error message, just this warning:

#

Now comes the strange part.

If for some reason, for example, I remove the signIn() callback, it works and i log in correctly in NextJS

thorny seal
#

To me, it seems like this code should be done in the signIn event. The error message is in regards to the return true; statement at the bottom of the callback

subtle flume
#

but the signIn callback, according to the docs, has to return true in case the user is allowed to signIn

#

for some reason, the await console.log(response); is not even printing anything. and the backend is not even receiving the request

thorny seal
#

Oh I see what you're doing

#

You're just missing a step

#

Basically what's happening currently is your provider completes sign-in and redirects to your app. Since you're authenticating with a Provider and not with Credentials or Email, the signIn callback is never triggered.

#

Wherever you're doing the signIn() function at, just make sure you don't pass a provider parameter. I assume right now it's signIn('google') or something like that. Then, you'll need to define a credential or email provider for your custom accounts in the DB. From there, it should start triggering the callback to determine if the user can or cannot sign in

subtle flume
#

Yeah. I am using signIn('google').
But the idea I had was to not use a credential or email provider because I just wanted to use Google and Facebook as providers and then send the email of the authenticated user to the backend and create a new database entry with that

#

I don't want to use custom accounts for now

#

but it doesn't seem to work for me

thorny seal
#

Google and Facebook will handle if a user is allowed to sign in or not, those providers will never trigger the signIn() callback simply because they do it on their own, and that logic is unnecessary. If you still want to make a call to your database after signIn, you should do so using the signIn() event

subtle flume
#

Ill make a quick test with the signIn event and report back here

#

I actually remember I tried this like two days ago and saw the same error message

#

The connectivity between my NextJS app and my Spring boot backend works fine because I've tested other endpoints in other parts of my app

thorny seal
#

Your springboot backend doesn't require credentials to post to?

subtle flume
#

nah, works fine from postman without anything

#

i permit all traffic for now

thorny seal
#

Quickly with that, your postman is a GET request and your axios is a POST request

#

Change postman to POST and re-verify

subtle flume
#

yeah true, but it should give another type of error

#

im trying anyway

#

also fyi:

#

signIn callback does actually get called even with GoogleProvider

#

check "hello" being printed

thorny seal
#

Hm, that is the exact opposite of the next-auth docs

#

In that case, I can only image that something is wrong with the axious request

subtle flume
#

tried with GET in the event, still same error

#

something seems wrong here

#

why isn't the axios request going through, so strange

thorny seal
#

When you did a POST on postman, did that go through?

subtle flume
#

oh no, but atleast you get an answer by the server:

thorny seal
#

Maybe Sprintboot requires a PUT

subtle flume
#

imma try to downgrade node

#

since im using node 18

thorny seal
#

Before you do, according to that post you can just change localhost:8080 to 127.0.0.1:8080, that's a quick attempt

#

Otherwise, downgrading may not be a bad option as long as it doesn't break other things haha

subtle flume
#

nah no luck

#

this sucks

#

specially when theres legit no one else facing the same issue in the whole internet haha

subtle flume
#

Ok this is why I definetly need to buy a mac already

#

turns out I was running my spring boot backend server under the IntelliJ IDE (on windows), and my NextJS app under WSL2 (ubuntu). Apparently, from WSL to the Windows host there is no connection by using "localhost". I had to use the static local ip instead like "http://192.168.1.39:8080/v1/auth/login"

#

Imagine spending 8h+ days stuck in something like this, trying legit everything possible

#

How frustrating