Lean
Authentication in Nuxt 3 using an Express.JS API
I was wondering what would be the best way of integrating my already existing Express.JS based API into Nuxt 3 and use its features.
I already tried a guide that mentioned 'useCookie()', but from my testing, that doesnt persist across page reloads. Currently experimenting with Pinia, but that doesnt seem to work across reloads as well.
Its a simple user-password based auth API that returns a jwt after logging in and after that every request is validated by sending the token in an auth header and in return receives the ID of the user.
2 replies
New to web dev, need help with authentication system.
To start off, im not completely sure if this is even the right place, but i want to create an auth system for my website. Im using Nuxt and Vuetify for the front and express.js in the back. Ive already created a registration route for my backend which saves the data in a mysql database, the data is sent to the backend using axios. I also have a really primitive login route, that currently, gets the Name, Surname and password(for verification) from the database
Now, my problem is that i have no idea how to do the login part. I suppose i have to generate somekind of a token that stores the user info, like name, surname and email in it but dont know how to do that + where to store it and how to use the auth module, or store, or both. The same goes for middleware, as i believe, i need to use that if i need to protect a frontend route.
29 replies