-
Notifications
You must be signed in to change notification settings - Fork 93
feat: Generate static redirects for simple Next.js redirects #3040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
google-labs-jules
wants to merge
1
commit into
main
Choose a base branch
from
feat/static-redirects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…Next.js redirects. This change adds the ability to generate static Netlify redirects for a subset of the Next.js redirects you defined in `next.config.js`. This will offload simple redirects to Netlify's edge, which should reduce function invocations and improve performance. I added a new `setRedirectsConfig` function that handles these simple redirects, including those with placeholders and splats, by converting them to the Netlify redirect format. Complex redirects that use `has`, `missing`, or regex-based sources will continue to be handled by the serverless function at runtime, just as they were before. To ensure everything works correctly, I've added unit tests to verify the redirect generation logic. I also added an E2E test to confirm that simple redirects are handled by the edge, while complex ones are correctly passed to the serverless function. For this, the E2E test uses the `debug-x-nf-function-type` header to differentiate between edge-handled and function-handled responses. Finally, I refactored the E2E test into separate, descriptively named tests for each redirect case to improve readability and maintainability.
📊 Package size report 0.04%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
None yet
0 participants
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.
This change implements a stopgap solution to generate static Netlify redirects for simple Next.js redirects, reducing serverless function invocations.