Skip to content

feat: send X-Spoo-Client header on all spoo.me API requests - #4

Merged
Zingzy merged 1 commit into
mainfrom
feat/client-header
Jul 22, 2026
Merged

feat: send X-Spoo-Client header on all spoo.me API requests#4
Zingzy merged 1 commit into
mainfrom
feat/client-header

Conversation

@Zingzy

@Zingzy Zingzy commented Jul 22, 2026

Copy link
Copy Markdown
Member

Every request the extension makes to the spoo.me backend now carries an X-Spoo-Client: snap/<version> header (the version comes from the extension manifest, currently snap/2.0.0). This lets the API attribute traffic by client.

The header name and value live in src/lib/constants.ts and are injected centrally in the api client's request() function, plus the few raw fetch call sites: device code exchange in the background worker, the two token refresh paths, stats export, and the v0 stats fallback.

The header is only ever sent to API_BASE_URL endpoints. QR code image URLs are plain GET image sources, and no third-party host receives the header.

All requests originate from the background service worker or extension pages (popup and side panel), which hold host permissions for spoo.me, so they are exempt from CORS and no server-side header allowance is needed for this to work. The content script makes no network requests.

Adds a client attribution header (snap/<version>) to every request
hitting the spoo.me backend, injected centrally in the api client
and on the few raw fetch call sites (device auth, refresh, export,
v0 stats). QR image URLs and third-party hosts are untouched.
Copilot AI review requested due to automatic review settings July 22, 2026 13:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Zingzy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24ffe7b3-50bd-4d89-a6e3-b33701c24ee0

📥 Commits

Reviewing files that changed from the base of the PR and between 0533ec0 and b176698.

📒 Files selected for processing (6)
  • src/api/auth.ts
  • src/api/client.ts
  • src/api/export.ts
  • src/api/stats.ts
  • src/entrypoints/background/index.ts
  • src/lib/constants.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/client-header

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Zingzy Zingzy left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mergeable, nothing blocking.

  • The central request() covers the 401-retry path too: the retry reuses the same headers object, so the tag survives the token refresh.
  • The four raw sites are the complete set. I grepped every fetch( in src: everything else flows through tagged paths, and the QR endpoints are consumed as image URLs so headers cannot apply there anyway.
  • browser.runtime.getManifest().version at module scope means the version can never drift from the manifest, and extension contexts always have browser available. Manifest versions fit the backend's 16-char version shape.
  • Both copies of refreshAccessToken (auth.ts and client.ts) got patched; the duplication itself predates this PR.
  • Lint, typecheck and build are green in CI.

@Zingzy
Zingzy merged commit 1bfd643 into main Jul 22, 2026
2 checks passed
@Zingzy
Zingzy deleted the feat/client-header branch August 16, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants