1

I know this might look like a familiar error which has been asked before, however I do think this is different. I ran a couple of testsand failed to find out (with all the solutions posted in other questions) what's going wrong.

I use a Docker container for local development on Laravel projects. I recently got a new project from a developer which won't run in my docker container and keeps giving me 419 errors after every form submit. Can't login etc etc.

This docker container is already being used for 11 other laravel projects which are working perfectly fine.

I tried to change the session driver to cookie in case of writing errors to the storage folder. Without any luck.

I checked if the forms added an csrf token and they do.

Request

What else can I try?

  • 419 is CSRF token issue. This is duplicate question. – Gabriel Apr 21 '20 at 09:35
  • Does this answer your question? [Post request in Laravel - Error - 419 Sorry, your session has expired](https://stackoverflow.com/questions/52583886/post-request-in-laravel-error-419-sorry-your-session-has-expired) – Gabriel Apr 21 '20 at 09:36
  • @Gabriel No. That is exactly my problem there is a CSRF token. If you can check the image I have attached. the csrf is also filled in in the form data. And to check if it isn't a storage issue i tried different session drivers without luck. So sadly enough this doesn't answer my problem. – Menno van Hout Apr 21 '20 at 10:38
  • It seems that laravel isn't setting the session cookie. It's creating the file in storage/framework/sessions but not setting the cookie at the user end. Tried to downgrade to php 7.2 instead of 7.4 without any luck. Also googled why this session isn't being set without luck. – Menno van Hout Apr 21 '20 at 12:11
  • Have you tried to turn off the middleware VerifyCriefToken check? Did you check permission for the session directory? – Kaushik Thakkar Apr 21 '20 at 20:47
  • @KaushikThakkar Yes. The permissions are correct the files are also being created. Removing the middleware works but that's absolutly not wanted ofcours. – Menno van Hout Apr 23 '20 at 08:57
  • have you tried clearing your cache ? `php artisan config:cache` – Kaushik Thakkar Apr 26 '20 at 17:24
  • What's your URL to access the project? Can you share it? – Kaushik Thakkar Apr 26 '20 at 17:25
  • Yes withoyt luck. I tried both using localhost and added a record to my host file like domain.test and tried different approaches in the .env file. Seems that the docker version isn't creating a sesison cookie on the browser. but why – Menno van Hout Apr 26 '20 at 22:56
  • @MennovanHout how did you get this resolved i think i am having the same issue only in a docker environment? – ahmed waleed Oct 16 '20 at 06:55
  • @ahmedwaleed Hi there! Sadly enough I never hot it resolved. I returned the project to my customer. It stays really weird to my. My own projects all work perfectly fine with docker but somehow the developer before me messed it up. – Menno van Hout Oct 17 '20 at 12:07
  • 1
    I resolved it, in my case, there was a space before – ahmed waleed Oct 19 '20 at 07:34
  • @ahmedwaleed Thanks for letting me know! that could be the issue yeah. Bit weird that it breaks everything. Thanks for letting me now! – Menno van Hout Oct 19 '20 at 20:15
  • I resolved it, in my case, there was a space before – Abin Rimal Nov 01 '22 at 12:23

1 Answers1

0

In my case it was incorrect domain set in .env APP_HOST=domain.com. Cookies won't work in this case because actual domain doesn't match with the one in APP_HOST

dgpro
  • 347
  • 3
  • 10