diff --git a/src/proxy/anthropic.ts b/src/proxy/anthropic.ts index b94eab7..a99108d 100644 --- a/src/proxy/anthropic.ts +++ b/src/proxy/anthropic.ts @@ -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, ]; diff --git a/src/proxy/middleware/request/index.ts b/src/proxy/middleware/request/index.ts index d27e356..42d1daa 100644 --- a/src/proxy/middleware/request/index.ts +++ b/src/proxy/middleware/request/index.ts @@ -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"; /** diff --git a/src/proxy/middleware/request/remove-origin.ts b/src/proxy/middleware/request/remove-origin.ts new file mode 100644 index 0000000..75bbc25 --- /dev/null +++ b/src/proxy/middleware/request/remove-origin.ts @@ -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", ""); +}; diff --git a/src/proxy/openai.ts b/src/proxy/openai.ts index c68330e..8ceeb5f 100644 --- a/src/proxy/openai.ts +++ b/src/proxy/openai.ts @@ -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, ];