Skip to content

Rename /__ts/page-bids to /_ts/page-bids for internal-route naming consistency #942

Description

@aram356

Summary

/__ts/page-bids is the only internal Trusted Server URL path that uses a double-underscore (__) prefix. Every other internal route lives under the single-underscore /_ts/ namespace. Rename the route to /_ts/page-bids so the internal-path convention is consistent.

Current state

Non-compliant (double underscore):

  • /__ts/page-bids

All other internal routes use /_ts/:

  • /_ts/set-tester, /_ts/clear-tester
  • /_ts/admin/keys/rotate, /_ts/admin/keys/deactivate
  • /_ts/api/v1/identify, /_ts/api/v1/batch-sync
  • /_ts/debug/ja4

A survey of URL string literals confirms /__ts/page-bids is the only path using __. (__ts_rsc_payload_ and the __tsjs_* window globals are internal JS identifiers, not URL paths, so they are out of scope.)

There is also an existing internal inconsistency that suggests the __ was unintentional: the unit test make_page_bids_request already builds its request with the single-underscore form /_ts/page-bids (crates/trusted-server-core/src/publisher.rs ~L4945), even though the route is registered as /__ts/page-bids. The test passes only because the same-origin gate inspects headers/Fetch-Metadata, not the path.

Scope — references to update in lockstep (~42 occurrences)

The tsjs client and the server route must agree on the path, so all of these change together:

Server route registration (all four adapters):

  • crates/trusted-server-adapter-fastly/src/app.rs:1086
  • crates/trusted-server-adapter-axum/src/app.rs:331
  • crates/trusted-server-adapter-cloudflare/src/app.rs:487, 494
  • crates/trusted-server-adapter-spin/src/app.rs:153, 734, 736

Client (must match the served bundle):

  • crates/trusted-server-js/lib/src/integrations/gpt/index.ts:731 (the fetch), plus the doc at L699

Tests + docs:

  • crates/trusted-server-integration-tests/tests/parity.rs:705-707
  • crates/trusted-server-core/src/publisher.rs:2337 (doc comment), and align the test at ~L4945 (already uses /_ts/)
  • any references under docs/

Compatibility / rollout note

The browser runs whatever tsjs bundle the server served it, so a single atomic deploy updates client + server together. However, already-cached/older bundles in the wild will keep requesting /__ts/page-bids, and on a Next.js SPA that path drives ad delivery for in-session navigations — a hard rename would drop ads for those clients until their bundle refreshes.

Recommended rollout:

  1. Register both /__ts/page-bids (deprecated alias) and /_ts/page-bids, routing to the same handler.
  2. Switch the client fetch to /_ts/page-bids.
  3. After old bundles have aged out of caches, remove the /__ts/page-bids alias.

Acceptance criteria

  • The route is served at /_ts/page-bids across all four adapters.
  • The tsjs client fetches /_ts/page-bids.
  • Parity tests, unit tests, and docs reference the single-underscore path.
  • A transition alias for /__ts/page-bids exists (and a follow-up to remove it), so no ad-serving gap during rollout.
  • No other internal URL paths use a __ prefix (confirmed: /__ts/page-bids is the only one).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions