Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ced2718's avatar

Inertia 419 error with docker

Hello,

I am having a small issue when trying to set my docker containers for a test environment.

Here is my current docker-compose file (at least the relevant part):

I am basically setting up a laravel/vue app which uses inertia for the communication between the two. I can spin up the containers just fine, access the app on localhost and everything works great.

However, I am now trying to setup Cypress on my app container (for simplicity, I included Cypress as a npm package and not as a separate container). I then set the CYPRESS_BASE_URL variable to be able to access the app (for some reason, trying to do host.docker.internal does not seem to be working), and some of my tests are running fine.

However, all the tests involving a POST request to the backend through Inertia are actually failing with a 419 error. I guess this is a CSRF issue since I am using to htpp://nginx (sorry, can't put links in here apparently so I misspelled it intentionally) and inertia can either not resolve this to an IP address or there is a domain configuration issue in that case?

Did anyone ever face a similar issue?

Thank you!

0 likes
1 reply
ced2718's avatar
ced2718
OP
Best Answer
Level 1

Apparently, the XSRF-TOKEN wasn't set properly which lead to this error. Adding this to my .env file solved my issue:

SESSION_DOMAIN=false #Only on dev
SESSION_SECURE_COOKIE=false #Only on dev
1 like

Please or to participate in this conversation.