Verify canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
Binaries:
Node: 16.17.0
npm: 8.15.0
Yarn: 1.22.19
pnpm: 7.1.0
Relevant packages:
next: 13.1.7-canary.10
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/beautiful-montalcini-vdnznm?file=%2Fmiddleware.ts%3A2%2C1
To Reproduce
Just open the reproduction example.
Describe the Bug
-
Can't import "server-only" files into middleware.
-
Importing "use server" files into middleware handles it as client file. So for example environment isn't available and code that relies on it breaks.
Expected Behavior
The explained problems not happening.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1616
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023 Binaries: Node: 16.17.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: 7.1.0 Relevant packages: next: 13.1.7-canary.10 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/beautiful-montalcini-vdnznm?file=%2Fmiddleware.ts%3A2%2C1
To Reproduce
Just open the reproduction example.
Describe the Bug
Can't import "server-only" files into middleware.
Importing "use server" files into middleware handles it as client file. So for example environment isn't available and code that relies on it breaks.
Expected Behavior
The explained problems not happening.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1616