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

miguellima's avatar

Redirect after POST call

Hello everyone,

So I'm submitting my form using fetch method, and then I return a redirect.

But it is not following the redirect.

Any Thoughts?

Thanks, Miguel

0 likes
2 replies
Nakov's avatar

You cannot return a redirect if you are using fetch on the client side. You should handle the redirect on the client side as well. So

fetch(
    //do the post here
).then(function() { 
    // handle your redirect here, if it was successful. 
});
1 like

Please or to participate in this conversation.