-
Notifications
You must be signed in to change notification settings - Fork 166
fix: middleware type #922
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
fix: middleware type #922
Conversation
🦋 Changeset detectedLatest commit: c487b2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Coverage Report
File Coverage
|
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 refactors the middleware configuration type so that OpenNextConfig.middleware
can be either an external or internal middleware config, and updates all related logic to use the new types.
- Introduces
CommonMiddlewareConfig
,ExternalMiddlewareConfig
, andInternalMiddlewareConfig
and updatesOpenNextConfig.middleware
. - Updates resolver, output generation, and adapter code to cast and use
ExternalMiddlewareConfig
. - Adjusts override extraction in
createGenericHandler
and adds conditional validation for external middleware.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/open-next/src/types/open-next.ts | Refactored middleware types and updated OpenNextConfig to use ExternalMiddlewareConfig or InternalMiddlewareConfig . |
packages/open-next/src/core/resolve.ts | Changed resolveOriginResolver signature to accept ExternalMiddlewareConfig originResolver. |
packages/open-next/src/core/createGenericHandler.ts | Guard override extraction to only pull .override when present on handler config. |
packages/open-next/src/build/validateConfig.ts | Added validateFunctionOptions call for middleware only when external === true . |
packages/open-next/src/build/generateOutput.ts | Extracted middlewareConfig for external middleware and updated originResolver/override access. |
packages/open-next/src/adapters/middleware.ts | Cast global config to ExternalMiddlewareConfig and updated all resolver calls to use the cast config. |
.changeset/slimy-turkeys-smoke.md | Added changeset entry for middleware configuration type fix. |
Comments suppressed due to low confidence (3)
packages/open-next/src/types/open-next.ts:424
- [nitpick] The docblock above
middleware
only mentions external behavior. Consider expanding it to also describe howexternal: false
(internal middleware) is handled.
middleware?: ExternalMiddlewareConfig | InternalMiddlewareConfig;
packages/open-next/src/build/validateConfig.ts:112
- Add unit tests for
validateConfig
to cover bothexternal: true
andexternal: false
middleware cases, ensuring validation logic runs only for external middleware.
if (config.middleware?.external === true) {
packages/open-next/src/adapters/middleware.ts:38
- The optional chaining on
middlewareConfig?.originResolver
causes a type mismatch:resolveOriginResolver
expects a non-undefinedoriginResolver
. Remove the?
so you passmiddlewareConfig.originResolver
.
middlewareConfig?.originResolver,
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
Co-authored-by: conico974 <[email protected]>
Thanks for the review Nico! |
assetResolver
can be used regardless if the middleware is external