LoginRadius / loginradius-react

LoginRadius React SDK
MIT License
5 stars 9 forks source link

Next.js Auth Not Working #6

Closed nefejames closed 2 years ago

nefejames commented 2 years ago

I can't seem to get your react SDK to work properly with Next.js. I'm able to log in, but not log out.

I passed in http://localhost:3000/ as a string directly where window.location.origin was used in the docs. I've whitelisted localhost in my dashboard. However, I can't log out.

<button onClick={() => logout({ returnTo: "http://localhost:3000/" })}>

When I try logging out, I'm told, "The host is not whitelisted. ", and it is whitelisted.

Please look into this.

Capture

Akash-Patil commented 2 years ago

Hi @mohammed786 ,

I am interested in working on this issue. Please assign this to me. Thanks.

mohammed786 commented 2 years ago

Hi @Akash-Patil Assigned this issue to you

Akash-Patil commented 2 years ago

Hi @nefejames,

I have tested this issue in a React app and it is working fine for me. It should work the same with Next.js as well as there are no specific changes in the code pertaining to this. Can you provide some more info on the matter through some code snippets or possibly a repo link of your use case? It would help me decipher the issue quicker.

Also try using just http:localhost in your LoginRadius dashboard instead of http://localhost:3000/ and see if it works once.

Regards, @Akash-Patil

nefejames commented 2 years ago

Hi @Akash-Patil

I started a new app from scratch, but I'm still getting errors. I see up this sandbox. I'm running on localhost, so could you test this locally. Clearly I'm missing something.

I'm having issues with the redirecting once the user logs in

mohammed786 commented 2 years ago

Hi @nefejames I have tried running your the code, Currently onClick of Log In button Event object is passing as an argument of loginWithRedirect method. try modifying the loginWithRedirect function call something like this

<button onClick={() => loginWithRedirect()}>Log in</button>

Also updated the ReadMe with proper implementation