PageSourceSearch

https://smartsearch-ebx.pages.dev/agent-proxy-sw.js

js smartsearch-ebx.pages.dev collected 2026-10-03 05:55:54 UTC 899 bytes, 34 lines download raw bytes

1/* Proxies Algolia Agent Studio calls through same-origin /api/agent (avoids CORS). */
2const STUDIO_PREFIX = '/agent-studio/1';
3
4self.addEventListener('install', (event) => {
5  event.waitUntil(self.skipWaiting());
6});
7
8self.addEventListener('activate', (event) => {
9  event.waitUntil(self.clients.claim());
10});
11
12self.addEventListener('fetch', (event) => {
13  const { request } = event;
14  if (request.method !== 'POST') return;
15
16  let url;
17  try {
18    url = new URL(request.url);
19  } catch {
20    return;
21  }
22
23  if (!url.hostname.endsWith('.algolia.net')) return;
24  if (!url.pathname.startsWith(STUDIO_PREFIX)) return;
25
26  const proxyPath = url.pathname.slice(STUDIO_PREFIX.length) || '/';
27  const proxyUrl = `${self.location.origin}/api/agent${proxyPath}${url.search}`;
28
29  event.respondWith(fetch(proxyUrl, {
30    method: request.method,
31    headers: request.headers,
32    body: request.body,
33  }));
34});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.