@meistrari/chat-nuxt 4.5.1-rc.5 → 4.5.1-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { H3Event } from 'h3';
|
|
2
|
+
export declare function isEdgeHeader(name: string): boolean;
|
|
3
|
+
export declare const fetchWithoutEdgeHeaders: typeof fetch;
|
|
2
4
|
export type ChatApiVersion = 'v1' | 'v2';
|
|
3
5
|
export declare function resolveChatBasePath(basePath: string, apiVersion: ChatApiVersion): string;
|
|
4
6
|
export declare function mapVaultProxyPath(path: string): string;
|
|
@@ -9,6 +9,26 @@ const CHAT_COMPAT_HEADERS = [
|
|
|
9
9
|
"x-chat-tela-agent-branch",
|
|
10
10
|
"x-chat-conversation-scope"
|
|
11
11
|
];
|
|
12
|
+
const EDGE_HEADER_PREFIXES = ["cf-", "x-forwarded-", "x-railway-", "x-envoy-"];
|
|
13
|
+
const EDGE_HEADERS = /* @__PURE__ */ new Set([
|
|
14
|
+
"cdn-loop",
|
|
15
|
+
"forwarded",
|
|
16
|
+
"true-client-ip",
|
|
17
|
+
"x-real-ip"
|
|
18
|
+
]);
|
|
19
|
+
export function isEdgeHeader(name) {
|
|
20
|
+
const lowerName = name.toLowerCase();
|
|
21
|
+
return EDGE_HEADERS.has(lowerName) || EDGE_HEADER_PREFIXES.some((prefix) => lowerName.startsWith(prefix));
|
|
22
|
+
}
|
|
23
|
+
export const fetchWithoutEdgeHeaders = (input, init) => {
|
|
24
|
+
const headers = new Headers(init?.headers);
|
|
25
|
+
for (const name of [...headers.keys()]) {
|
|
26
|
+
if (isEdgeHeader(name)) {
|
|
27
|
+
headers.delete(name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return fetch(input, { ...init, headers });
|
|
31
|
+
};
|
|
12
32
|
function normalizeProxyPath(path) {
|
|
13
33
|
const segments = path.split("/").map((segment) => segment.trim()).filter(Boolean);
|
|
14
34
|
for (const segment of segments) {
|
|
@@ -162,6 +182,7 @@ export async function proxyChatApiRequest(event, targetPath, options = {}) {
|
|
|
162
182
|
const headers = buildProxyHeaders(event);
|
|
163
183
|
try {
|
|
164
184
|
return await proxyRequest(event, targetUrl, {
|
|
185
|
+
fetch: fetchWithoutEdgeHeaders,
|
|
165
186
|
fetchOptions: {
|
|
166
187
|
redirect: "manual"
|
|
167
188
|
},
|