Skip to content

Invalid CSRF Token

Technical Support
20 11 18.3k 5

Suggested Topics


  • Invalid CSRF token when authenticating via third-party app

    Unsolved Technical Support
    7
    1 Votes
    7 Posts
    3k Views
    S
    @hnipps said in Invalid CSRF token when authenticating via third-party app: I'm trying to use NodeBB as a headless forum (i.e. just a REST API with a separate front end) but keep getting an "invalid csrf token" error when I try to authenticate. I've confirmed I can authenticate via the NodeBB UI on the same instance. I've also tried getting the NodeBB config and using the csrf token from there in my requests but it still does not work. My frontend is a NextJS app that rewrites all /api/:path* requests to http://<MY-NODE-BB-INSTANCE>/api/:path*. It also rewrites the auth paths. I can see the requests reach NodeBB but always get "invalid csrf token". I've verified that I can successfully call GET endpoints from my app, e.g. I can get the user list from /api/users. This is a 2 yr old thread, but @hnipps have you gone any further with the React/NextJS frontend with a headless nodebb? If you have made any progress I would love to contribute on the frontend build. It is daunting to start as a new project but if any foundations were laid I would love to jump in and build upon it.
  • Invalid CSRF Token, again

    Technical Support
    9
    0 Votes
    9 Posts
    5k Views
    T
    Hello, This problem persists in version v1.17.2. The invalid csrf token error happens occassionaly when updating existing topics. Single tab open in single browser.
  • Problem with invalid csrf token on registration/login

    Technical Support
    1
    0 Votes
    1 Posts
    573 Views
    J
    I am running a nodebb 1.15.0 system on Ubuntu 20 on nginx. It's a newer install and we've had an occasional issue on both registration and login where folks will get a message denying their login or registration. 2020-11-12T06:11:19.312Z [4567/17870] - error: /register invalid csrf token or 2020-11-12T06:11:13.910Z [4567/17870] - error: /login invalid csrf token Frequently a refresh on the browser will let a user login or sometimes just waiting a few minutes. Here's my config.json { "url": "https://opposite-lock.com", "secret": "secret", "database": "mongo", "port": "4567", "mongo": { "host": "127.0.0.1", "port": "27017", "username": "nodebb", "password": "secret", "database": "nodebb", "uri": "" } } Nginx config server { server_name opposite-lock.com; client_max_body_size 100M; 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_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:4567; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/opposite-lock.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/opposite-lock.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = opposite-lock.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name opposite-lock.com; return 404; # managed by Certbot } Any help would be very much appreciated!
  • 1 Votes
    4 Posts
    4k Views
    julianJ
    Thanks for the update @amarinelli
  • invalid csrf token in NodeBB 0.7.x

    Technical Support
    3
    0 Votes
    3 Posts
    3k Views
    M
    I've found the issue. The problem was coming from the varnish's configuration, which was playing the set-cookie value.

Looks like your connection to NodeBB Community was lost, please wait while we try to reconnect.