I noticed that during the development of my Laravel app the return redirect() sometimes doesnt work when I try to register or login into my app. I hit the submit button and the page just keeps loading and I can see that chrome says "processing" and keeps spinning, so I have to manually click the browser refresh button in order to get redirected to the account page meaning that the user successfully logged in or registered.
But sometimes it works just fine which is strange.
So today I tried to clear the Laravel cache and browser cache
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
And do a "empty cache and hard reload" on chrome
After that I tried to register a user, and this time redirect didnt work again.
So I checked telescope to look at the headers and noticed this:
The times redirect doesnt work I can see:
referer: "https://www.mysite.test/login",
origin: "https://www.mysite.test",
host: "www.mysite.test"
And the times when redirect works the headers looks like this:
referer: "https://mysite.test/login",
origin: "https://mysite.test",
host: "mysite.test"
So why is "www" added to the url when I clear the cache and why does adding "www" keeps redirect() from working?
I am running my app through Valet if that matters