-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
🐛 The bug
In src/runtime/server/proxy-handler.ts, proxied request bodies are always read and may be transformed, even for compressed binary payloads. This can corrupt or stall analytics requests (e.g. PostHog by default uses gzip-js with compression=gzip-js), leading to repeated proxy timeouts (504 Upstream timeout).
Relevant code (current main)
From src/runtime/server/proxy-handler.ts:
- Body is always read for write methods:
if (method === 'POST' || method === 'PUT' || method === 'PATCH')(~208)rawBody = await readBody(event)(~209)
- Privacy branch transforms based on parsed/string body:
if (anyPrivacy && rawBody)(~211)
- Forwarded request body is rebuilt:
body: body ? (typeof body === 'string' ? body : JSON.stringify(body)) : undefined(~292)
- Timeout is hardcoded:
const timeoutId = setTimeout(() => controller.abort(), 15000)(~285)
- On fetch error:
- returns 204 only for
/collect,/tr,/events(~303) - otherwise throws
message: 'Failed to reach upstream'(~312)
- returns 204 only for
🛠️ To reproduce
https://stackblitz.com/edit/nuxt-starter-bcwumula?file=nuxt.config.ts
🌈 Expected behavior
Proxy should preserve raw request bytes for endpoints/content-types that are not explicitly safe to parse and rewrite, and only apply body privacy transforms where parsing is guaranteed valid.
ℹ️ Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working