fix: change redirect default status from 302 to 307#3671
Closed
ddmoney420 wants to merge 1 commit intodenoland:mainfrom
Closed
fix: change redirect default status from 302 to 307#3671ddmoney420 wants to merge 1 commit intodenoland:mainfrom
ddmoney420 wants to merge 1 commit intodenoland:mainfrom
Conversation
Changes the default redirect status code from 302 to 307 to preserve
the original HTTP method on redirect. This fixes POST redirects being
converted to GET requests when using basepath.
Per RFC 7231:
- 302 Found: User agents MAY change POST to GET (browsers do this)
- 307 Temporary Redirect: Method MUST NOT be changed
Users who explicitly need 302 behavior can still pass it:
`ctx.redirect("/path", 302)`
Fixes denoland#2632
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
Closing this PR as part of cleaning up my contributions. I spread too thin across projects. Apologies for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes the default redirect status code from 302 to 307 to preserve the original HTTP method on redirect.
This fixes POST redirects being converted to GET requests when using basepath configuration.
Problem
Per RFC 7231:
The current default of 302 breaks form submissions when redirecting, as POST requests become GET requests.
Solution
Change the default status in
ctx.redirect()from 302 to 307.Users who explicitly need 302 behavior can still pass it:
Test plan
Fixes #2632
🤖 Generated with Claude Code