-
Notifications
You must be signed in to change notification settings - Fork 89
fix: support named & default export for middleware in ntl dev #2116
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
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
middleware = nextMiddleware.middleware | ||
|
||
// The middleware file can export a named `middleware` export or a `default` export | ||
middleware = isFunction(nextMiddleware.middleware) ? nextMiddleware.middleware : nextMiddleware.default |
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.
Is the function check necessary? I imagine nextMiddleware.middleware
is undefined
if the default
exists?
middleware = isFunction(nextMiddleware.middleware) ? nextMiddleware.middleware : nextMiddleware.default | |
middleware = nextMiddleware.middleware ?? nextMiddleware.default |
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.
Someone could for some reason export a named middleware
that is for them some utility. Better safe than sorry
Description
As explained in amannn/next-intl#290 (comment) it seems that both a named
middleware
export and adefault
export is supported.This allows both for
netlify dev
when we import the middleware.Documentation
N/A
Tests
No tests were added but I tried the change manually on the repository shared in #2106
You can test this change yourself like so:
Relevant links (GitHub issues, etc.) or a picture of cute animal
Fixes #2106