inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.01k stars 224 forks source link

Safari can not handle redirect()->back() #581

Closed StefanNeuser closed 4 months ago

StefanNeuser commented 7 months ago

When we use return redirect()->back() instead of return redirect()->route(...) Safari is going to load / root url. Anybody also forcing that problem? We have that issue only in Safari within a iFrame application so far :-(

Replacing back() with route() is not the way to go about it because of the Validation handling with a redirect()->back()

Any ideas, what could cause to that issue?

RobertBoes commented 7 months ago

That sounds like a cookie/session and/or referer issue. Laravel uses the referer to determine the previous URL (https://github.com/laravel/framework/blob/10.x/src/Illuminate/Routing/UrlGenerator.php#L166) with a fallback to sessions. For example, if you're using a Referrer-Policy and have it set to origin the browser would only send the domain as the referrer, thus Laravel would interpret that as being the previous page URL. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy. If it's not sent at all (no-referrer) then Laravel will fallback to sessions.