inertiajs / inertia-laravel

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

Should Inertia middleware call session()->setPreviousUrl? #607

Closed mikethea1 closed 3 months ago

mikethea1 commented 3 months ago

We have a laravel/react/inertia application that uses router.visit() for navigation on the front-end.

Since router.visit() sends X-Requested-With as XmlHttpRequest, laravel's StartSession middleware does not store the page GET in session with setPreviousUrl().

As a result, if you hit a validation error and laravel tries to bounce you back to the last successful URL, you might not end up on the intended page.

Is this something that's been considered?

driesvints commented 3 months ago

Heya. In this case I think it's best if you attempt a PR so the maintainers can have a look at the code involved to make this happen. Thanks!

mikethea1 commented 3 months ago

@driesvints is it possible to have a discussion on what the behavior should be before code is written? As-is I would consider this a bug in Inertia, but maybe there is some reason why this is by design. I'd like to understand.

Also, why was the issue closed?

driesvints commented 3 months ago

Right now we don't handle support questions through this channel. If you want to introduce something please send in a PR so the maintainers can review and perhaps also give an explanation why this is the way it it 👍

mikethea1 commented 3 months ago

@driesvints sorry for filing this in the wrong place. Where do you expect bug reports to be filed?

driesvints commented 3 months ago

@mikethea1 this isn't a bug, just something that's not supported right now. Like I said: if you want this to be supported please attempt a PR.

mikethea1 commented 3 months ago

this isn't a bug, just something that's not supported right now

Thanks @driesvints , this is the info I was after.

if you want this to be supported please attempt a PR

Will do!