Why Turbo breaks all 302 redirects?

It seems that Turbo does not handle 302 properly. You need to use 303 instead.

This breaks all existing applications, all redirect_to needs to be changed, Devise and other gems are broken…

Is it a Turbo bug that will be fixed? Otherwise, why this breaking change!?

Isn’t it better to handle the 302 normally as in the past?

No idea why they made the change, but there’s an upgrade guide for existing apps that handles redirect properly:

1 Like

I believe it has to do with Turbo using the fetch API under the hood for all of its requests. The spec for how the fetch API works responds to 302s differently if they are not GET or POST requests.

The discussion here outlines what is happening:

1 Like

Facing same Issue. Did you find any solution.

I think there are a few possible solutions:

  1. Convert it to a button
  2. Handle turbo in format.turbo_stream
  3. Return a 303 or :see_other in the redirect

Look at seanpdoyle’s messages in this thread Unintended consequences of deleting a record with turbo_method:delete · Issue #301 · hotwired/turbo-rails · GitHub

1 Like