2

I have my frontend using React/Next.JS, and I'm wanting to implement Google OAuth for authentication to the users info in the backend.

On the backend, I'm using Express and Passport for routing and authentication respectively. I got all of this working with just the plain username and password, however I decided that I would rather have this with just using OAuth services.

So the current flow:

User on FRONTEND clicks "Login with Google", which redirects them to BACKEND/login/google, which then of course handles logging in with Google, which then once its done redirects to BACKEND/login/google/callback, which will then redirect you to the frontend.

Now here's the issue. On the callback route in my backend, calling Request.isAuthenticated() works just fine. However once the user has navigated back to the frontend, each subsequent request is not authenticated.

My thought here is that since the user is technically being logged in on the backend, the session is being tied to the backend.

What would be a proper way of handling this type of scenario?

4

0 回答 0