crater-invoice/crater

CSRF Token mismatch

robdid opened this issue · 3 comments

robdid commented

Describe the bug
Unable to connect to Crater on another device on my local network. I tried multiple browsers and devices including incognito mode. I always get the error « CSRF token mismatch » (see screenshot).

Crater was installed on a M1 iMac via the terminal with Docker Desktop running in the background. I followed the steps from the install guide and then accessed the iMac’s localhost through its IP adress on the local network.

Crater is running fine on the iMac.

I tried creating other users on crater but the authentification on the other devices still failed.

Screenshots
IMG_1440

Please complete the following information:

  • Crater version: 6.06
  • PHP version: 8.1.20

Optional info

  • OS: Mac OS 13.4
  • Hardware: M1 iMac
  • Browser: chrome/safari/arc

I had the same error when installing via Docker compose, running in an Ubuntu VM, everything was working fine until I restarted the VM

These are the API calls that the app is doing:

imagen

Bootstrap call response:

{"message":"Unauthenticated."}

Logout call response:

{
    "message": "CSRF token mismatch.",
    "exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
    "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
    "line": 389,
    "trace": [
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
            "line": 332,
            "function": "prepareException",
            "class": "Illuminate\\Foundation\\Exceptions\\Handler",
            "type": "->"
        },
        {
            "file": "/var/www/app/Exceptions/Handler.php",
            "line": 51,
            "function": "render",
            "class": "Illuminate\\Foundation\\Exceptions\\Handler",
            "type": "->"
        },
        ...
        {
            "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 111,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/var/www/public/index.php",
            "line": 59,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        }
    ]
}

The issue happened to me because the IP of the VM changed, so I had to update the .env file with the new IP, these are the variables that I changed with the new IP:

APP_URL=
SANCTUM_STATEFUL_DOMAINS=
SESSION_DOMAIN=

And its working now