inertia icon indicating copy to clipboard operation
inertia copied to clipboard

always get 409 when use inertia or useForm

Open anditsung opened this issue 3 years ago • 5 comments

Versions:

  • @inertiajs/inertia version: #.#.#
  • @inertiajs/inertia-vue3 version: #.#.#

Describe the problem:

Steps to reproduce:

when use useForm or Inertia i always get 409 then redirect again to correct url but i dont have problem on using Link i already check the asset version is the same.

what could be the issue here?

anditsung avatar Jul 25 '22 03:07 anditsung

this likely has to do with the http request method being used when submitting an Inertia form and your laravel routes' accepted http request method being in conflict. Inertia links are using get requests which your laravel routes are correctly matching up with. Check the request methods being sent/used by your inertia forms and what is being accepted in your laravel routes file, especially put vs post.

If you still have trouble after that, you might consider posting more info like laravel routes, form code, etc. so people can help better.

ITwrx avatar Jul 26 '22 17:07 ITwrx

Screen Shot 2022-07-27 at 09 11 27

Route::get('live', [LiveController::class, 'index'])->name('interface.hmi.live');
Route::get('live/data', [LiveController::class, 'data'])->name('interface.hmi.live.data');

the method is correct but i got 2 request sent... this is confuse me cause i only send one the 1st request is get got response 409 the 2nd request is get got response 200

anditsung avatar Jul 27 '22 02:07 anditsung

if you requested http://127.0.0.1/interface/hmi/live?plant=A your route should start with interface/hmi/ as in Route::get('interface/hmi/live', [LiveController::class, 'index'])->name('interface.hmi.live');

Maybe you're trying to use the route name in your request url? (->name('interface.hmi.live')) If so, that name is for laravel-generated urls.

I got a 409 a while back and it was b/c my request didn't match my routes, IIRC.

You could also post the code that is making these troublesome requests.

ITwrx avatar Jul 27 '22 03:07 ITwrx

i register the route as group the url is match with my request. dont know if this has problem with laravel nova

route

Route::prefix('interface')->group(function () {
    Route::prefix('hmi')->group(function() {
        Route::get('live', [LiveController::class, 'index'])->name('interface.hmi.live');
        Route::get('live/data', [LiveController::class, 'data'])->name('interface.hmi.live.data');
    });
});

on inertia page

Inertia.get(route('interface.hmi.live'), pickBy(this.form), {
                    preserveState: true,
                    preserveScroll: true,
                })

also have try using this

this.form.post(route('interface.hmi.live')

anditsung avatar Jul 27 '22 04:07 anditsung

It seems you are trying to use named routes from Inertia, maybe via Ziggy? Perhaps try routing with standard Inertia-documented method. Using standard methods, i'm not seeing any errant requests of any kind in my testing projects. I tried using Ziggy at one point, but had some kind of package/dependency issues, IDR. You don't post versions or complete software info, so i can't guess what might be going on there. I would test without Nova, Ziggy or anything else involved in the routing, and go from there, adding each package and re-testing, on-by-one, to determine the culprit.

Posting to a get route might be a good way to get 400 errors (if that's what you did. it's not clear from your one-liner), but i would think it would be a 405, as opposed to 409.

I'm just a user like you, so i don't speak for the project, but in future issue reports for any software, especially largely-unfunded FOSS, you might consider posting all relevant code, as well as names and versions of the software involved in the issue, and/or just follow the issue reporting template. Your original report for this issue would likely be ignored by many projects/people.

Also, this is not likely to be an Inertia issue, IMHO.

ITwrx avatar Jul 27 '22 14:07 ITwrx

Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion.

In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.

Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it.

Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️

reinink avatar Jul 28 '23 01:07 reinink