removes origin/referer headers from proxied request

This commit is contained in:
nai-degen 2023-06-23 00:08:09 -05:00
parent db034a51b3
commit 602931bf7f
4 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import {
finalizeBody,
languageFilter,
limitOutputTokens,
removeOrigin,
} from "./middleware/request";
import {
ProxyResHandlerWithBody,
@ -75,6 +76,7 @@ const rewriteAnthropicRequest = (
blockZoomers,
languageFilter,
limitOutputTokens,
removeOrigin,
finalizeBody,
];

View File

@ -15,6 +15,7 @@ export { finalizeBody } from "./finalize-body";
export { languageFilter } from "./language-filter";
export { limitCompletions } from "./limit-completions";
export { limitOutputTokens } from "./limit-output-tokens";
export { removeOrigin } from "./remove-origin";
export { transformKoboldPayload } from "./transform-kobold-payload";
/**

View File

@ -0,0 +1,10 @@
import { ProxyRequestMiddleware } from ".";
/**
* Removes origin and referer headers before sending the request to the API for
* privacy reasons.
**/
export const removeOrigin: ProxyRequestMiddleware = (proxyReq) => {
proxyReq.setHeader("origin", "");
proxyReq.setHeader("referer", "");
};

View File

@ -15,6 +15,7 @@ import {
languageFilter,
limitCompletions,
limitOutputTokens,
removeOrigin,
} from "./middleware/request";
import {
createOnProxyResHandler,
@ -95,6 +96,7 @@ const rewriteRequest = (
languageFilter,
limitOutputTokens,
limitCompletions,
removeOrigin,
finalizeBody,
];