You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've cloned a ecommerce template (https://github.com/payloadcms/payload/tree/main/templates/ecommerce) to start working on a Next.js project. When I added a simple middleware as you often do in Next.js applications, it only runs on development using yarn dev but after building the project using yarn build && yarn serve it no longer works - it's not fired.
My middleware.ts file is placed inside /src folder and looks like this:
I was able to recreate this issue but have not been able to pinpoint a cause. A blank Next.js app of the same version does not have this issue. It likely has something to do with how we are invoking the nextBuild command.
Link to reproduction
No response
Describe the Bug
I've cloned a ecommerce template (https://github.com/payloadcms/payload/tree/main/templates/ecommerce) to start working on a Next.js project. When I added a simple middleware as you often do in Next.js applications, it only runs on development using
yarn dev
but after building the project usingyarn build && yarn serve
it no longer works - it's not fired.My middleware.ts file is placed inside
/src
folder and looks like this:Development:
After building the project it no longer fires (console.log is not visible).
Any idea how to make middleware work with Custom server?
To Reproduce
npx create-payload-app@latest my-project -t ecommerce
middleware.ts
file insidesrc/
folder (same level asserver.ts
file) with following content:yarn build && yarn serve
You won't be able to see a console.log inside a middleware file as opposite to running a project by
yarn dev
Payload Version
2.22.0
Adapters and Plugins
No response
The text was updated successfully, but these errors were encountered: