You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, my team's run into an interesting issue regarding POST requests that respond with redirects. We are on Rails 7.0.8.4 using Vue 3.x
Here's an example: we have two controller routes for working through a queue of "review" entities on our site. The show action shows a tabbed navbar (current_tab being the active tab in the nav). There's an optional param for search filters, and the queue prop is an array of "review" entities. Apologies for the generic nature of the code, I'm trying to redact for IP sensitivity.
def show
render inertia: 'Review/Show', props: {
tab: current_tab,
filters:,
queue:,
}
end
def complete_reviews
reviews.each(&:complete)
redirect_to review_path(
tab: current_tab,
filters: filters,
),
notice: "Reviews have been marked as complete."
end
When we execute a router.post in our javascript code, I can see the request in my Chrome inspector's network tab and I see a 302 response from the redirect. I also see that my browser follows the redirect and requests the page, receiving a 200 response. However, after receiving the 200 response, our Vue components do not update their state on the page. We have to refresh the browser tab manually to see the new application state. We have isolated this to POST requests only (using both router.post and <Link method="post">): when the request is modified to a GET with no additional code changes beyond those that would support the change in HTTP verb and using query params to send our data, everything works as intended.
According to the inertia-rails docs, Inertia-fied POST requests are intended to follow redirects.
The text was updated successfully, but these errors were encountered:
Hello, my team's run into an interesting issue regarding POST requests that respond with redirects. We are on Rails 7.0.8.4 using Vue 3.x
Here's an example: we have two controller routes for working through a queue of "review" entities on our site. The
show
action shows a tabbed navbar (current_tab
being the active tab in the nav). There's an optional param for search filters, and thequeue
prop is an array of "review" entities. Apologies for the generic nature of the code, I'm trying to redact for IP sensitivity.When we execute a
router.post
in our javascript code, I can see the request in my Chrome inspector's network tab and I see a302
response from the redirect. I also see that my browser follows the redirect and requests the page, receiving a200
response. However, after receiving the200
response, our Vue components do not update their state on the page. We have to refresh the browser tab manually to see the new application state. We have isolated this toPOST
requests only (using bothrouter.post
and<Link method="post">
): when the request is modified to aGET
with no additional code changes beyond those that would support the change in HTTP verb and using query params to send our data, everything works as intended.According to the inertia-rails docs, Inertia-fied POST requests are intended to follow redirects.
The text was updated successfully, but these errors were encountered: