Commit bc54caa
authored
Make first-party integration URLs root-relative (#819)
* 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.
* Address PR review: fix DataDome doc example and note base-href tradeoff1 parent 5447648 commit bc54caa
5 files changed
Lines changed: 50 additions & 61 deletions
File tree
- crates/trusted-server-core/src/integrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
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 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
821 | 823 | | |
822 | 824 | | |
823 | 825 | | |
| |||
1328 | 1330 | | |
1329 | 1331 | | |
1330 | 1332 | | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
| 1333 | + | |
1335 | 1334 | | |
1336 | 1335 | | |
1337 | 1336 | | |
| |||
1340 | 1339 | | |
1341 | 1340 | | |
1342 | 1341 | | |
1343 | | - | |
1344 | | - | |
1345 | | - | |
1346 | | - | |
| 1342 | + | |
1347 | 1343 | | |
1348 | 1344 | | |
1349 | 1345 | | |
| |||
1368 | 1364 | | |
1369 | 1365 | | |
1370 | 1366 | | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
| 1367 | + | |
1375 | 1368 | | |
1376 | 1369 | | |
1377 | 1370 | | |
| |||
1380 | 1373 | | |
1381 | 1374 | | |
1382 | 1375 | | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
| 1376 | + | |
1387 | 1377 | | |
1388 | 1378 | | |
1389 | 1379 | | |
| |||
1392 | 1382 | | |
1393 | 1383 | | |
1394 | 1384 | | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
| 1385 | + | |
1399 | 1386 | | |
1400 | 1387 | | |
1401 | 1388 | | |
| |||
| 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 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
| |||
587 | 589 | | |
588 | 590 | | |
589 | 591 | | |
590 | | - | |
591 | | - | |
| 592 | + | |
| 593 | + | |
592 | 594 | | |
593 | 595 | | |
594 | 596 | | |
| |||
| 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 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
426 | 428 | | |
427 | 429 | | |
428 | 430 | | |
| |||
532 | 534 | | |
533 | 535 | | |
534 | 536 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
| 537 | + | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
| 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 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
440 | 442 | | |
441 | 443 | | |
442 | 444 | | |
| |||
547 | 549 | | |
548 | 550 | | |
549 | 551 | | |
550 | | - | |
| 552 | + | |
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
| |||
Lines changed: 10 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 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
308 | 306 | | |
309 | 307 | | |
310 | 308 | | |
| |||
851 | 849 | | |
852 | 850 | | |
853 | 851 | | |
854 | | - | |
| 852 | + | |
855 | 853 | | |
856 | 854 | | |
857 | 855 | | |
858 | | - | |
| 856 | + | |
859 | 857 | | |
860 | 858 | | |
861 | 859 | | |
| |||
986 | 984 | | |
987 | 985 | | |
988 | 986 | | |
989 | | - | |
| 987 | + | |
990 | 988 | | |
991 | 989 | | |
992 | 990 | | |
| |||
0 commit comments