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
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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):
version: "3.9"
services:
app:
build:
context: .
dockerfile: docker/Dockerfile.dev
container_name: app
environment:
CYPRESS_BASE_URL: htpp://nginx
DISPLAY: ${DISPLAY}
volumes:
- .:/app
- /app/vendor
- /app/node_modules
ports:
- 5173:5173
restart: unless-stopped
depends_on:
- mysql
networks:
- network
nginx:
image: nginx:1.24.0
container_name: nginx
- .:/app
ports:
- 80:80
restart: unless-stopped
depends_on:
- app
networks:
- network
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!
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
Please or to participate in this conversation.