Environment
node: v18.12.0
nuxt: 3.4.0
Reproduction
This is the code for the server middleware in my Nuxt project:
export default defineEventHandler((event) => {
const backendEndpoint = 'https://api.mybackend.com'
const pathsWithProxyToBackend = ['/api', '/storage']
if (event.node.req.url) {
if (pathsWithProxyToBackend?.filter((path: string) => event.node.req.url?.startsWith(path))?.length > 0) {
return proxyRequest(event, new URL(event.node.req.url, backendEndpoint).toString())
}
}
return
})
Describe the bug
Some of my requests throw 500 error
[nuxt] [request error] [unhandled] [500] Cannot read properties of null (reading 'Symbol(Symbol.asyncIterator)') 20:30:53
at sendProxy (./node_modules/h3/dist/index.mjs:552:38)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.handler (./node_modules/h3/dist/index.mjs:1247:19)
at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1322:7)
There is no logic ...
On next page refresh other requests throws same error (500 code) (or no errors and all requests are 200 code)
Please help! Thanks
Additional context
No response
Logs
Nuxt response with error
{
"url": "/storage/releases/posters/9407/xRI8qpbLlmYGn0gy__faeb17923a3a62917671d76d38019a15.webp",
"statusCode": 500,
"statusMessage": "",
"message": "Cannot read properties of null (reading 'Symbol(Symbol.asyncIterator)')",
"stack": "<pre><span class=\"stack internal\">at sendProxy (./node_modules/h3/dist/index.mjs:552:38)</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at async Object.handler (./node_modules/h3/dist/index.mjs:1247:19)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1322:7)</span></pre>"
}
Response headers of request
HTTP/1.1 500 Not Modified
Access-Control-Allow-Origin: *
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cache-control: max-age=14400
cf-cache-status: MISS
cf-ray: 7b7dade0d8331c0-OSL
date: Fri, 14 Apr 2023 17:30:53 GMT
etag: "6433cfc-3ac"
last-modified: Mon, 10 Apr 2023 08:58:50 GMT
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
referrer-policy: no-referrer-when-downgrade
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=ZBgKefuS7%2FBCMgT93ZMXv0akCngAvd8TF%2FXVUtr64yf%2FSnUxsrV9PX1D"}],"group":"cf-nel","max_age":604800}
server: cloudflare
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
content-type: application/json
content-length: 663
Environment
node: v18.12.0
nuxt: 3.4.0
Reproduction
This is the code for the server middleware in my Nuxt project:
Describe the bug
Some of my requests throw 500 error
There is no logic ...
On next page refresh other requests throws same error (500 code) (or no errors and all requests are 200 code)
Please help! Thanks
Additional context
No response
Logs
Nuxt response with error
Response headers of request