'How to preserve current GET url in the browser while making POST request to server in Laravel-8 and InertiaJs

I am using Inertia JS in Laravel 8, with following POST request to server. The problem is that the browser URL is also updated with POST request, which may be a expected behavior in some cases but I want to keep the actual GET request in the browser despite sending different types of requests to server using multiple Laravel routes.

this.$inertia.put(`/task/${task_id}`, {order, category_id});

this.$inertia.visit(`/task/${task_id}`, {
    method: 'put',
    data: {order, category_id},
    only: ['categories', 'msg'],
    replace: true,
    preserveState: true,
    preserveScroll: true,
});
                

Does anybody have the idea, how I can preserve existing GET URL in the browser while send POST requests to server using Inertia JS?



Solution 1:[1]

you can try remove the replace: true

Solution 2:[2]

in your task controller, use return Redirect::route('your_original_route');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BlackLotus
Solution 2 bguiz