I think the middleware is causing the issue.
Removing runtime: 'nodejs' from the config object in the middleware.ts fixed the issue for me.
runtime: 'nodejs'
config
middleware.ts