fix: use Response.redirect in redirectToPreviewURL#134
Closed
angeloashmore wants to merge 1 commit intomainfrom
Closed
fix: use Response.redirect in redirectToPreviewURL#134angeloashmore wants to merge 1 commit intomainfrom
angeloashmore wants to merge 1 commit intomainfrom
Conversation
…irectToPreviewURL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| (await draftMode()).enable(); | ||
|
|
||
| redirect(previewURL); | ||
| return Response.redirect(new URL(previewURL, request.url), 307); |
There was a problem hiding this comment.
Base path redirect handling regressed
Medium Severity
Response.redirect(new URL(previewURL, request.url), 307) builds a raw URL and bypasses Next.js redirect normalization. When the app uses a basePath, redirects based on previewURL can resolve outside that prefix, sending users to the wrong path and causing preview routes to fail.
Member
Author
|
This PR is no longer needed. The underlying fix was done in #133. |
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.


Resolves:
Description
redirectToPreviewURLwas using Next.js'sredirect()fromnext/navigation, which throws internally to signal a redirect. This is incompatible with Route Handlers that need to return aResponse. Switching toResponse.redirect()makes the function return a proper response object and removes the dependency on Next.js internals.Checklist
Preview
How to QA 1
Note
Medium Risk
Changes the exported function’s return type and redirect mechanism, which may affect consumers relying on Next.js
redirect()semantics or expecting anever-returning helper.Overview
redirectToPreviewURLnow returns aResponseusingResponse.redirect(...)(307) rather than calling Next.jsredirect()fromnext/navigation.This updates the function signature from
Promise<never>toPromise<Response>and constructs an absolute redirect target vianew URL(previewURL, request.url)to be compatible with Route Handlers.Written by Cursor Bugbot for commit 9441cc3. This will update automatically on new commits. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩