Skip to content

Only add x-fah-middleware header to routes that have middleware enabled - #325

Merged
mathu97 merged 8 commits into
mainfrom
feat/scope-down-middleware-routes
May 2, 2025
Merged

Only add x-fah-middleware header to routes that have middleware enabled#325
mathu97 merged 8 commits into
mainfrom
feat/scope-down-middleware-routes

Conversation

@mathu97

@mathu97 mathu97 commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

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 the middleware-manifest.json to get the routes that middleware is enabled on, and updating the routes-manifest.json file with the x-fah-middleware headers.

Testing this change locally:

  1. Added a middleware.ts file that only matches the /blah route.
Screenshot 2025-05-02 at 12 13 54 PM
  1. Build the app with the NextJs Adapter
  2. Ran the app and saw the x-fah-middleware header only being added to the /blah route
Screenshot 2025-05-02 at 12 33 40 PM Screenshot 2025-05-02 at 12 34 04 PM

@mathu97
mathu97 marked this pull request as ready for review April 11, 2025 16:54
@mathu97 mathu97 changed the title Only add x-fah-middleware routes to routes that have middleware enabled Only add x-fah-middleware header to routes that have middleware enabled Apr 11, 2025

@annajowang annajowang left a comment

Copy link
Copy Markdown
Collaborator

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

Comment thread packages/@apphosting/adapter-nextjs/src/overrides.ts
@mathu97
mathu97 requested a review from leoortizz as a code owner May 2, 2025 16:38
@mathu97
mathu97 merged commit 126f46c into main May 2, 2025
@mathu97
mathu97 deleted the feat/scope-down-middleware-routes branch May 2, 2025 17:26
jamesdaniels pushed a commit that referenced this pull request May 20, 2025
…ed (#325)

* only add x-fah-middleware routes to routes that have middleware enabled

* start tests

* fix bug and fix unit tests

* fixup e2e tests

* fix lint error

* fix e2e

* bump adapter version
richwear1307 pushed a commit to richwear1307/horse-tipping-app that referenced this pull request Feb 27, 2026
…ed (firebase#325)

* only add x-fah-middleware routes to routes that have middleware enabled

* start tests

* fix bug and fix unit tests

* fixup e2e tests

* fix lint error

* fix e2e

* bump adapter version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants