fix(ai): honor NO_PROXY ports for secure websockets
This commit is contained in:
@@ -61,7 +61,7 @@ export function shouldBypassProxy(urlObj: URL): boolean {
|
||||
.map(r => r.trim())
|
||||
.filter(Boolean);
|
||||
const targetHost = urlObj.hostname.toLowerCase();
|
||||
const targetPort = urlObj.port || (urlObj.protocol === "https:" ? "443" : "80");
|
||||
const targetPort = urlObj.port || (urlObj.protocol === "https:" || urlObj.protocol === "wss:" ? "443" : "80");
|
||||
|
||||
for (const rule of rules) {
|
||||
if (rule === "*") {
|
||||
|
||||
@@ -1466,7 +1466,7 @@ describe("openai-codex streaming", () => {
|
||||
|
||||
it("bypasses configured proxies for NO_PROXY websocket targets", async () => {
|
||||
Bun.env.PI_PROXY_CODEX_PROXY_TEST = "http://127.0.0.1:7890";
|
||||
Bun.env.NO_PROXY = "chatgpt.com";
|
||||
Bun.env.NO_PROXY = "chatgpt.com:443";
|
||||
__resetProxyCache();
|
||||
let capturedProxy: string | undefined;
|
||||
class NoProxyWebSocket extends MockWebSocket {
|
||||
|
||||
@@ -190,6 +190,11 @@ describe("shouldBypassProxy NO_PROXY rules", () => {
|
||||
expect(shouldBypassProxy(new URL("https://api.sakana.ai/v1"))).toBe(false);
|
||||
expect(shouldBypassProxy(new URL("http://api.sakana.ai:8080/v1"))).toBe(true);
|
||||
});
|
||||
|
||||
it("uses port 443 for secure websocket targets", () => {
|
||||
Bun.env.NO_PROXY = "api.sakana.ai:443";
|
||||
expect(shouldBypassProxy(new URL("wss://api.sakana.ai/v1"))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("wrapFetchForProxy", () => {
|
||||
|
||||
Reference in New Issue
Block a user