Commit b08256f
committed
Make first-party integration URLs root-relative
The GPT, DataDome, Permutive, Lockr, and Sourcepoint attribute rewriters
rewrote a publisher's `<script src>` / `<link href>` to an absolute first-party
URL built from `request_host`, e.g. `https://{request_host}/integrations/gpt/script`.
When the host that reaches the program isn't the page's host — behind a
host-rewriting dev proxy, or any deployment where `request_host` resolves to the
routing host rather than the production domain — those URLs leak the wrong host
into the page (e.g. `https://ts.example.com/integrations/...` while the address
bar shows `www.example.com`).
Emit them root-relative (`/integrations/...`) instead, so the browser resolves
them against the page's own host. This is correct both in production and behind
a proxy, removes the dependency on `request_host`/`X-Forwarded-Host` derivation,
and matches what GTM, Didomi, Testlight, and these integrations' own inline-script
rewriters already do.
Audited every integration: these five were the only page-facing first-party URLs
built from a host. NextJS RSC/flight payload rewriting stays absolute (those URLs
are intentional). The DataDome protection module's raw-`Host` read is server-side
(validation API body), not page-facing, and is left as-is. Tests updated to
assert the root-relative form.1 parent 5447648 commit b08256f
5 files changed
Lines changed: 29 additions & 60 deletions
File tree
- crates/trusted-server-core/src/integrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
806 | | - | |
| 806 | + | |
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
| 817 | + | |
| 818 | + | |
821 | 819 | | |
822 | 820 | | |
823 | 821 | | |
| |||
1328 | 1326 | | |
1329 | 1327 | | |
1330 | 1328 | | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
| 1329 | + | |
1335 | 1330 | | |
1336 | 1331 | | |
1337 | 1332 | | |
| |||
1340 | 1335 | | |
1341 | 1336 | | |
1342 | 1337 | | |
1343 | | - | |
1344 | | - | |
1345 | | - | |
1346 | | - | |
| 1338 | + | |
1347 | 1339 | | |
1348 | 1340 | | |
1349 | 1341 | | |
| |||
1368 | 1360 | | |
1369 | 1361 | | |
1370 | 1362 | | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
| 1363 | + | |
1375 | 1364 | | |
1376 | 1365 | | |
1377 | 1366 | | |
| |||
1380 | 1369 | | |
1381 | 1370 | | |
1382 | 1371 | | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
| 1372 | + | |
1387 | 1373 | | |
1388 | 1374 | | |
1389 | 1375 | | |
| |||
1392 | 1378 | | |
1393 | 1379 | | |
1394 | 1380 | | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
| 1381 | + | |
1399 | 1382 | | |
1400 | 1383 | | |
1401 | 1384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 445 | + | |
| 446 | + | |
449 | 447 | | |
450 | 448 | | |
451 | 449 | | |
| |||
587 | 585 | | |
588 | 586 | | |
589 | 587 | | |
590 | | - | |
591 | | - | |
| 588 | + | |
| 589 | + | |
592 | 590 | | |
593 | 591 | | |
594 | 592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 422 | + | |
| 423 | + | |
426 | 424 | | |
427 | 425 | | |
428 | 426 | | |
| |||
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
| 533 | + | |
| 534 | + | |
539 | 535 | | |
540 | 536 | | |
541 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
440 | 438 | | |
441 | 439 | | |
442 | 440 | | |
| |||
547 | 545 | | |
548 | 546 | | |
549 | 547 | | |
550 | | - | |
| 548 | + | |
551 | 549 | | |
552 | 550 | | |
553 | 551 | | |
| |||
Lines changed: 6 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 288 | + | |
293 | 289 | | |
294 | 290 | | |
295 | 291 | | |
| |||
301 | 297 | | |
302 | 298 | | |
303 | 299 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 300 | + | |
| 301 | + | |
308 | 302 | | |
309 | 303 | | |
310 | 304 | | |
| |||
851 | 845 | | |
852 | 846 | | |
853 | 847 | | |
854 | | - | |
| 848 | + | |
855 | 849 | | |
856 | 850 | | |
857 | 851 | | |
858 | | - | |
| 852 | + | |
859 | 853 | | |
860 | 854 | | |
861 | 855 | | |
| |||
986 | 980 | | |
987 | 981 | | |
988 | 982 | | |
989 | | - | |
| 983 | + | |
990 | 984 | | |
991 | 985 | | |
992 | 986 | | |
| |||
0 commit comments