Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
Views
@nuxtjs/auth-next Page Refresh Invalidates Session

I am using the @nuxtjs/auth-next module for JWT Authentication with an Express server.

Auth Config (nuxt.config.js)

auth: {
localStorage: false,
strategies: {
  local: {
    token: {
      property: 'token',
      global: true,
      required: true,
      type: 'Bearer',
    },
    user: {
      property: 'user',
      autoFetch: true,
    },
    endpoints: {
      login: { url: '/api/auth/login', method: 'post' },
      logout: { url: '/api/auth/logout', method: 'post' },
      user: { url: '/api/auth/user', method: 'get' },
    },
  },
},
cookie: {
  prefix: 'premium.',
  options: {
    secure: true,
  },
},
redirect: {
  login: '/',
  logout: '/',
  callback: '/',
  home: '/dashboard',
},
},

The login works perfectly fine and other routes can be browsed to, but once the site is refreshed the user gets logged out. The cookies are still set and the token is valid (tested with Postman). I also tested the routes.

Nginx Config

server {

# SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
# ... I left out ssl certs

server_name mydomain.com;

gzip            on;
gzip_types      text/plain application/xml text/css application/javascript;
gzip_min_length 1000;

# The Nuxt app
location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;

    proxy_read_timeout          1m;
    proxy_connect_timeout       1m;

    proxy_pass http://127.0.0.1:8000;
    proxy_redirect off;


}

   # The express server on same domain
   location ~ /api/* {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_read_timeout          1m;
        proxy_connect_timeout       1m;

        rewrite ^/api/(.*) /$1 break;
        proxy_pass http://127.0.0.1:1337;
        proxy_redirect off;
      }
     }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!