how do companies handle auth and restricted pages if used seperate backend
Unanswered
German Shepherd Dog posted this in #help-forum
German Shepherd DogOP
let's say I have a python backend login and login with google endpoints .
the
the
I'm new to NextJS that has SSR and SSG . most people use NextAuth but they tend to use it if their apis is inside app/api .
so if my backend is in python , should I use nextauth or manual way (auth context) .
if NextAuth is preferred , how do I set up the CredentialProvider and GoogleProvider ? because I don't use the nextjs's apis router
if the other way is preferred , how do I do that ? how do I handle the session to accessibe with SSR and SSG ? can I just see some of the repositories that have this configured please , thanks
the
login accepts post method (username and password) and returns access_token,refresh_token,user_detailthe
login/google accepts post method (code generated by google oauth) and returns access_token,refresh_token,user_detailI'm new to NextJS that has SSR and SSG . most people use NextAuth but they tend to use it if their apis is inside app/api .
so if my backend is in python , should I use nextauth or manual way (auth context) .
if NextAuth is preferred , how do I set up the CredentialProvider and GoogleProvider ? because I don't use the nextjs's apis router
if the other way is preferred , how do I do that ? how do I handle the session to accessibe with SSR and SSG ? can I just see some of the repositories that have this configured please , thanks
1 Reply
I just want to help a bit:
In SSG you'd need to resort to client-side authentication as Next.js can't build the page statically if it requires authentication server-side
As per nextauth, you can choose to integrate it with your custom back-end however, do note that NextAuth prefers if that one user is onnly connected to one provider.
So if you set up using NextAuth, a user will either be authenticated using Google, or your Custom Python Backend.
However, after authentication, both user can still interact with your custom backend to store or fetch data. So only the authentication part is delegated to NextAuth.
This is as far as I can tell you. I haven't looked if any repo exist to testify if its practically possible
In SSG you'd need to resort to client-side authentication as Next.js can't build the page statically if it requires authentication server-side
As per nextauth, you can choose to integrate it with your custom back-end however, do note that NextAuth prefers if that one user is onnly connected to one provider.
So if you set up using NextAuth, a user will either be authenticated using Google, or your Custom Python Backend.
However, after authentication, both user can still interact with your custom backend to store or fetch data. So only the authentication part is delegated to NextAuth.
This is as far as I can tell you. I haven't looked if any repo exist to testify if its practically possible