Proxy drops image/jpeg upload bodies because binary content-type allowlist only includes image/png
## Summary
Nango Proxy appears to drop request bodies for direct binary uploads with `Content-Type: image/jpeg`.
We hit this while uploading receipt attachments to Xero through Nango Proxy. The same flow works for PDFs, but JPEG uploads reach Xero as an empty file.
## Observed behavior
Client sends a `PUT` request through Nango Proxy with:
- `Content-Type: image/jpeg`
- nonzero `Content-Length`
- binary JPEG body
Nango forwards the request to Xero, but Xero receives the attachment as empty and returns:
```text
The file to be attached must have some content.
```
Xero's error payload showed `ContentLength: 0`.
## Expected behavior
Nango Proxy should preserve and forward the binary request body for `image/jpeg`, the same way it does for `application/pdf` and `application/octet-stream`.
## Suspected root cause
In current `master`, public proxy body parsing depends on:
```ts
bodyParser.raw({
type: (req) => isBinaryContentType(req.headers['content-type']),
limit: bodyLimit
})
```
`isBinaryContentType()` uses this allowlist:
```ts
const BINARY_CONTENT_TYPES = [
'image/png',
'video/',
'audio/',
'application/',
'text/',
'font/',
'model/',
'message/',
'chemical/',
'x-world/',
'application/octet-stream'
];
```
Because this includes `image/png` but not `image/jpeg` or broad `image/`, JPEG request bodies are not raw-parsed and the proxy forwards an empty body.
## Suggested fix
Change the image MIME allowlist from:
```ts
'image/png'
```
to:
```ts
'image/'
```
or explicitly add common image upload types such as:
```ts
'image/jpeg',
'image/jpg',
'image/webp',
'image/heic'
```
A regression test for `Content-Type: image/jpeg` proxy uploads would be useful.
## Related PRs
This looks related to, but not fully covered by:
- #2708
- #3551
- #2643
#3551 added more binary upload support, but current `master` still appears to miss `image/jpeg`.
1 条评论