NextAuth with a Rest API
So I have 3 Servers:
- API (should handle login with nextauth)
- Admin
- Customer
Currently we aren’t using nextauth, just email, password logins.
We want customers to login just with their email (Email-Provider) and the Admins with Credentials ( force yubikey ).
Now I am having problems setting up nextauth.
My first two solutions where:
1. Open API/api/auth/Admin/Signum OR API/api/auth/Customer/signin -> go back to adminpage if auccess
2. POST Logins manually to the api routes
PROBLEMS:
1. The redirect to the original page doesn’t work.
2. CORS is blocking is
A new solution was to wrap the admin _app in a SeasionProvider and use the signIn function from NextAuth in the frontend.
My thought was with setting the NEXTAUTH_URL to the api url I could send the sign data to the API url and additionally could use “useSession” in the frontend.
Sadly this isn’t working.
Any Ideas to solve this issue?
1 Reply