I have a Laravel/InertiaJS application where I perform Axios requests from a Vue frontend to update some models. In my case, I have a Proposal display page that also displays the Tasks related to the proposal.
I have a Vue subcomponent that performs an Axios call to update a specific task:
const moveToNextStatus = (status) => { console.log('run') // update the status of the task using axios axios.patch(`/data/tasks/${props.task.id}`, { status: status }) }
This is the route it points to:
Route::patch('/data/tasks/{task}', [\App\Http\Controllers\TaskController::class, 'update'] )->name('tasks.update');
Then, in my Laravel TaskController, my update method looks like this:
public function update (Request $request, Task $task) { $task->update($request->all()); return redirect()->back(); }
For some reason, when Axios' request for PATCH /tasks/{task} fires, it also calls route PATCH /proposals/{proposal} and attempts to update the failed proposal. < /p>
Maybe this has something to do with redirecting from child components? Can anyone help me?
The documentation for Inertia states;
You can find this in the documentation here:https://inertiajs.com/redirects
It also expects you to use a non-standard helper for redirection, such as;
I don't agree with it, but it is what it is - using 303 when the page doesn't redirect at all seems to violate the network status code standard.