Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cipsas's avatar
Level 10

Post method redirect in middleware

Hi,

how to make redirect with same method in middleware? Now, when I make ajax POST request, it redirect to GET request

0 likes
3 replies
cipsas's avatar
Level 10

Thanks @blackbird for the link. I will try to dig in. But it looks quite complicated. I thought where is a simple way to handle it :) Something similar to:

redirect('/' . $request->path(), array( "method" =>$request->method() ))->->withInput(); 
bobbybouwmann's avatar

I haven't handled this before in middleware so I have no clue on the subject, your example might even work!

Please or to participate in this conversation.