Commit 07f9438
fix: normalize API target env vars to bare hostnames via URL parsing (#1799)
* fix: normalize API target env vars to strip scheme prefix
When --*-api-target values originate from GitHub Actions expressions
(e.g., ${{ vars.ANTHROPIC_BASE_URL }}), the scheme is not stripped at
compile time. At runtime the full URL (https://host) reaches the API
proxy, which prepends https:// again, producing double-scheme URLs
like https://https://host that Squid rejects.
Fix at two layers:
1. containers/api-proxy/server.js: add normalizeApiTarget() that
strips any http(s):// prefix. Applied to all four API targets
(OpenAI, Anthropic, Gemini, Copilot) on startup.
2. src/docker-manager.ts: add stripScheme() and apply it when
setting *_API_TARGET env vars in the api-proxy container. This
prevents the scheme from ever reaching the container.
Fixes #1795
Upstream: github/gh-aw#25137
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: normalize API targets to bare hostnames only
Use URL parsing in both normalizeApiTarget() and stripScheme() to
extract only the hostname, discarding path, query, fragment, port,
and credentials. Paths must use the separate *_API_BASE_PATH settings.
Addresses review feedback that target values are used as TLS SNI /
hostname in https.request(), so including paths would break requests.
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/ab65b061-c924-41d8-a573-dd954497def2
* fix: improve error message in normalizeApiTarget
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/ab65b061-c924-41d8-a573-dd954497def2
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>1 parent 8956001 commit 07f9438
File tree
4 files changed
+171
-11
lines changed- containers/api-proxy
- src
4 files changed
+171
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
67 | 104 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
71 | 109 | | |
72 | 110 | | |
73 | 111 | | |
| |||
123 | 161 | | |
124 | 162 | | |
125 | 163 | | |
126 | | - | |
| 164 | + | |
127 | 165 | | |
128 | 166 | | |
129 | 167 | | |
| |||
932 | 970 | | |
933 | 971 | | |
934 | 972 | | |
935 | | - | |
| 973 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
9 | 48 | | |
10 | 49 | | |
11 | 50 | | |
| |||
268 | 307 | | |
269 | 308 | | |
270 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
271 | 329 | | |
272 | 330 | | |
273 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
298 | 320 | | |
299 | 321 | | |
300 | 322 | | |
| |||
2439 | 2461 | | |
2440 | 2462 | | |
2441 | 2463 | | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
2442 | 2480 | | |
2443 | 2481 | | |
2444 | 2482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
375 | 398 | | |
376 | 399 | | |
377 | 400 | | |
| |||
1460 | 1483 | | |
1461 | 1484 | | |
1462 | 1485 | | |
1463 | | - | |
1464 | | - | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1465 | 1491 | | |
1466 | | - | |
| 1492 | + | |
1467 | 1493 | | |
1468 | | - | |
| 1494 | + | |
1469 | 1495 | | |
1470 | 1496 | | |
1471 | 1497 | | |
| |||
0 commit comments