Next.js Discord

Discord Forum

Auth with external Node.js app

Unanswered
Rose-breasted Grosbeak posted this in #help-forum
Open in Discord
Avatar
Rose-breasted GrosbeakOP
I have a production BE app running on Node.js and Express and I want to rewrite my client side app from plain React to Next.js with app router. I have my own auth set up already done.

Previously I was doing my auth with JWT and refresh tokens and was handling this without cookies. I want to change my approach and handle sessions through middleware on Next.js.

I am currently stuck as I don't understand how to approach both BE and FE set ups.

- How should the tokens be passed between requests? Perhaps, someone has an example of how to set up Auth with external Node.js BE which connects to Next.js as a reference? 🙏🏼

- How to handle refresh token functionality and is it crucial to have one?

3 Replies

Avatar
Silver
make a client of axios and use intercept in order to pass the token to the backend.
you can store the token in localstorage
Avatar
Rose-breasted GrosbeakOP
Storing token in localstorage is not a good practice..