Static site hosting via tangled
at main 706 B view raw
1import { Handler } from "./handler.js"; 2import { Config } from "./config.js"; 3import configObj from "../config.worker.example.json"; // must be set at build time 4 5const config = new Config(configObj); 6if (config.cache) { 7 throw new Error("Cache is not supported in worker mode"); 8} 9 10export default { 11 async fetch(request, env, ctx) { 12 const url = new URL(request.url); 13 const host = url.host; 14 const path = url.pathname; 15 const handler = await Handler.fromConfig(config); 16 const { status, content, contentType } = await handler.handleRequest({ 17 host, 18 path, 19 }); 20 return new Response(content, { 21 status, 22 headers: { "Content-Type": contentType }, 23 }); 24 }, 25};