-
Notifications
You must be signed in to change notification settings - Fork 107
Only add x-fah-middleware header to routes that have middleware enabled #325
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?
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.
lgtm from me on good looking code
} | ||
// Add the middleware header to all routes for which middleware is enabled | ||
const middlewareManifest = loadMiddlewareManifest(appPath, distDir); | ||
const rootMiddleware = middlewareManifest.middleware["/"]; |
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.
@jamesdaniels My assumption here was that we only need to look at the root key as NextJs now only supports middleware at the root directory. It used to support nested middleware while in beta which is why I think the API is like this.
Similar logic in Opennext AWS adapter: https://github.com/opennextjs/opennextjs-aws/blob/73281c958d43d865fdded0d5d86dd82747365fee/packages/open-next/src/core/routing/util.ts#L160-L174
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.
Yeah that's a good assumption
Currently
x-fah-middleware
header is being added to all routes of an app that has a middleware file.This PR updates the logic to only add
x-fah-middleware
header to routes that have middleware enabled. This is done by reading themiddleware-manifest.json
to get the routes that middleware is enabled on, and updating theroutes-manifest.json
file with thex-fah-middleware
headers.