Is it possible to access the (headers of the) 303 redirect response in a Turbo callback?
I tried turbo:before-fetch-response
and turbo:submit-end
but all I can find in event.detail
is the request that Turbo performs when following the redirect.
I think it would be great to have a callback that is executed between the 303 redirect and the request that follows the redirect.
I still have this problem… is there any way to access the 303 response? Specifically the headers I’m interested in…
Have you tried using the turbo:submit-end
event? Turbo Reference (hotwired.dev)
turbo:submit-end
fires after the form submission-initiated network request completes. Access the FormSubmission
object with event.detail.formSubmission
along with FormSubmissionResult
properties included within event.detail
.
I think it does contain the redirect url, the headers as well(if memory does not betray me ofc).
Unfortunately not, the fetchResponse
in turbo:submit-end
is also the one from the request after the 303 redirect.
But I got the answer in the GoRails discord: Turbo doesn’t have access to the 303 response since it’s handled by the Fetch API! So by the time Fetch hands over to Turbo again, the 303 response is already gone.