DEV Community


Discussion on: How to add authentication to your universal Nuxt app using nuxt/auth module?

zloypacifist profile image

I've made 2 api endpoints on my server localhost:8080 for login and profile.
On login endpoint: if user credentials is valid, set cookie 'myauth' with some unique value (token), and save this token for user in DB.
On profile endpoint: if cookie 'myauth' set and user found by token, return json with it's profile info, for example:
"id: 1,
"name": "Jon Snow",
"email": ""
else return 401 status code with empty response.

After this manipulating my nuxt app start to login users. I've used auth middleware in nuxt config for all routings. I've used Lumen framework for api server