mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: Parse body optionally in proxy
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
Parse body optionally in proxy
|
||||
@@ -78,11 +78,18 @@ export function createProxy(options: CreateProxyOptions = {}): Proxy {
|
||||
);
|
||||
}
|
||||
|
||||
const contentLength = req.headers.get('content-length');
|
||||
const hasBody = contentLength && parseInt(contentLength) > 0;
|
||||
|
||||
let proxied = new Request(parsedUrl, {
|
||||
method: req.method,
|
||||
cache: 'no-cache',
|
||||
headers: req.headers,
|
||||
body: await req.arrayBuffer(),
|
||||
body:
|
||||
hasBody &&
|
||||
['POST', 'PUT', 'PATCH', 'DELETE'].includes(req.method.toUpperCase())
|
||||
? await req.arrayBuffer()
|
||||
: undefined,
|
||||
});
|
||||
|
||||
if (overrides?.request) {
|
||||
|
||||
Reference in New Issue
Block a user