Client side transition with middleware crashing #63186
Labels
bug
Issue was opened via the bug report template.
Pages Router
Related to Pages Router.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
https://github.com/Glumac7/middleware-issues
To Reproduce
In order to reproduce this issue, you need to do the following in order:
http://localhost:3000/test1
go to second page
buttonTypeError: Cannot read properties of undefined
How to make it "work":
next.config.js
, remove "api.ts" forpageExtensions
test2/234
instead of an_error.tsx
Alternatively, you could install next
v13.4.12
using which you would not need to make these changes tonext.config.js
, because the error occurs from13.4.13-canary.0
onward.Current vs. Expected behavior
Currently, we are getting an error presumably due to the middleware. There are no props in
_app.tsx
when there is a new build and a client side redirect happens on an active user session. When we remove"api.ts"
frompageExtensions
, that is, remove the use of the middleware, it works, on bothv13.4.12
andv13.4.13-canary.0
. If we want to use the middleware, we would need to downgrade tov13.4.12
.Expected behaviour should be the same as it is in
v13.4.12
(because the error happens fromv13.4.13-canary.0
onward), that is, for props returned fromgetInitialProps
and used in_app.tsx
not to beundefined
.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 Binaries: Node: 18.18.0 npm: 9.8.1 Yarn: N/A pnpm: N/A Relevant Packages: next: 14.1.3 eslint-config-next: 14.1.2 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Data fetching (gS(S)P, getInitialProps), Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Other (Deployed)
Additional context
It started happening from
v13.4.13-canary.0
onward, meaning it also happens on the newest next release (v14.1.3
as of this writing). Works as expected onv13.4.12
.The text was updated successfully, but these errors were encountered: