inertiajs / inertia-laravel

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

Form submission using GET instead of POST #660

Closed Scott-McMullan-ABB closed 2 months ago

Scott-McMullan-ABB commented 2 months ago

I have just setup a brand new Laravel App with Breeze/InertiaJS/Vue.

In my Login.vue component, I have the default form submission method

const submit = () => {
    form.post(route("login"), {
        onFinish: () => form.reset("password"),
    });
};

I've registered the login route in routes/auth.php

 Route::post('login', [AuthenticatedSessionController::class, 'store'])
        ->name('login');

When I submit the login for, though, I get the error

The GET method is not supported for route login. Supported methods: POST.

So, for some reason, it's GETting when it should be POSTing. I can't figure out why this is. Any help would be appreciated.

php: 8.2 inertiajs/inertia-laravel: 1.3 laravel/framework: 11.9

RobertBoes commented 2 months ago

What's likely happening here: there is a validation error, then Laravel will redirect back to the login page, which is done using a GET request. If you look at your browser's devtools you'll likely see a POST request followed up by a GET request

Scott-McMullan-ABB commented 2 months ago

@RobertBoes you're right, that's exactly what's happening. I think something is going wrong \App\Http\Controllers\Auth\AuthenticatedSessionController::store. I'll figure out the issue from there, thanks.