GET /xrpc/app.bsky.actor.searchActorsTypeahead typeahead.waow.tech
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

add X-Client header for traffic source identification

prefer X-Client over Origin for tracking, works from any context
(server-side, CLI, native). documented in /docs with code example.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+19 -3
+19 -3
src/index.ts
··· 60 60 const CORS_HEADERS = { 61 61 "Access-Control-Allow-Origin": "*", 62 62 "Access-Control-Allow-Methods": "GET, POST, OPTIONS", 63 - "Access-Control-Allow-Headers": "Content-Type, Authorization", 63 + "Access-Control-Allow-Headers": "Content-Type, Authorization, X-Client", 64 64 }; 65 65 66 66 const SLINGSHOT_URL = ··· 333 333 .run(); 334 334 } 335 335 336 - /** fire-and-forget: increment cumulative hit counter per origin domain */ 336 + /** fire-and-forget: increment cumulative hit counter per client identity */ 337 337 async function recordTrafficSource(db: TursoDB, request: Request): Promise<void> { 338 + const client = request.headers.get("X-Client"); 338 339 const origin = request.headers.get("Origin"); 339 - const domain = origin ? new URL(origin).hostname : "unknown"; 340 + const domain = client || (origin ? new URL(origin).hostname : "unknown"); 340 341 await db.prepare( 341 342 `INSERT INTO traffic_sources (domain, hits) 342 343 VALUES (?1, 1) ··· 1448 1449 <p> 1449 1450 extracting the base URL into a constant (or env var) makes it easy to switch back 1450 1451 if you ever need to. 1452 + </p> 1453 + 1454 + <h2>identify your app</h2> 1455 + <p> 1456 + set the <code>X-Client</code> header so your app shows up by name in our 1457 + <a href="/stats">traffic stats</a> instead of as "unknown": 1458 + </p> 1459 + <pre><code>const response = await fetch( 1460 + \`\${TYPEAHEAD_URL}/xrpc/app.bsky.actor.searchActorsTypeahead?q=\${encodeURIComponent(query)}&amp;limit=10\`, 1461 + { headers: { 'X-Client': 'my-app.example.com' } } 1462 + );</code></pre> 1463 + <p> 1464 + use your domain or app name — whatever you want to be identified as. 1465 + browser-based apps will also be identified automatically via the <code>Origin</code> header, 1466 + but <code>X-Client</code> is preferred since it works everywhere (server-side, CLI, native apps). 1451 1467 </p> 1452 1468 1453 1469 <h2>response comparison</h2>