-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat: rewrite redirects sent through the proxy #139
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
base: main
Are you sure you want to change the base?
feat: rewrite redirects sent through the proxy #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for rewriting redirect responses when proxying API requests, ensuring redirects are properly handled in both SSR and client-side contexts. The feature is controlled by a new experimental configuration option rewriteProxyRedirects (enabled by default).
Key changes:
- Implements redirect rewriting logic for proxied requests, handling relative, absolute, and same-origin redirects
- Adds configuration option to enable/disable the feature
- Includes test coverage for various redirect scenarios
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/runtime/server/proxyHandler.ts |
Core implementation of redirect rewriting logic with helper functions |
src/module.ts |
Adds configuration option and server template for the feature |
test/fixture/server/api/redirect.get.ts |
Test fixture for various redirect scenarios |
test/e2e-proxy.test.ts |
E2E tests validating redirect rewriting behavior |
src/runtime/server/handler.ts |
Adds header to track redirected responses |
playground/server/api/custom/redirect.ts |
Playground endpoint for testing redirects |
playground/server/api/custom/echo.ts |
Playground endpoint for testing requests |
playground/nuxt.config.ts |
Adds custom endpoint to playground configuration |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| addTemplate({ | ||
| filename: `module/${moduleName}.config.d.ts`, | ||
| write: false, // Internal config, no need to write to disk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out addTemplate forces write = true when the filename ends in .d.ts lol
π Linked issue
β Type of change
π Description
Rewrite redirects if for some reason an API uses them.
Also moves the config template typing to a static .d.ts file with module declarations, as it was the best way to add typing for server templates.
π Checklist