export default {
  async fetch(request) {
    const upstream = await fetch("http://cr3.broadcasturself.com:1982/stream", {
      headers: {
        "Icy-MetaData": "1",
        "User-Agent": "SmurfettesWorker/1.0"
      }
    });

    const headers = new Headers(upstream.headers);
    headers.set("Content-Type", "audio/mpeg");
    headers.set("Access-Control-Allow-Origin", "*");
    headers.set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
    headers.delete("content-security-policy");
    headers.delete("x-frame-options");

    return new Response(upstream.body, {
      status: upstream.status,
      statusText: upstream.statusText,
      headers,
    });
  }
};
