mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
fix: posthog reverse proxy
This commit is contained in:
@ -19,22 +19,28 @@ const posthogProxy = async (request: Request) => {
|
|||||||
const headers = new Headers(request.headers);
|
const headers = new Headers(request.headers);
|
||||||
headers.set('host', hostname);
|
headers.set('host', hostname);
|
||||||
|
|
||||||
headers.delete('connection');
|
const fetchOptions: RequestInit = {
|
||||||
headers.delete('content-length');
|
|
||||||
headers.delete('cookie');
|
|
||||||
|
|
||||||
const response = await fetch(newUrl, {
|
|
||||||
method: request.method,
|
method: request.method,
|
||||||
headers,
|
headers,
|
||||||
body: request.body,
|
redirect: 'follow',
|
||||||
// @ts-expect-error - Not really sure about this
|
};
|
||||||
duplex: 'half',
|
|
||||||
});
|
if (!['GET', 'HEAD'].includes(request.method)) {
|
||||||
|
fetchOptions.body = request.body;
|
||||||
|
fetchOptions.duplex = 'half';
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(newUrl, fetchOptions);
|
||||||
|
|
||||||
|
const responseHeaders = new Headers(response.headers);
|
||||||
|
responseHeaders.delete('content-encoding');
|
||||||
|
responseHeaders.delete('content-length');
|
||||||
|
responseHeaders.delete('transfer-encoding');
|
||||||
|
|
||||||
return new Response(response.body, {
|
return new Response(response.body, {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
statusText: response.statusText,
|
statusText: response.statusText,
|
||||||
headers: response.headers,
|
headers: responseHeaders,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user