diff --git a/src/worker.ts b/src/worker.ts new file mode 100644 index 0000000..7d4dcc4 --- /dev/null +++ b/src/worker.ts @@ -0,0 +1,21 @@ +export default { + async fetch(request: Request, env: { ASSETS: Fetcher }): Promise { + const url = new URL(request.url); + + // Serve assets from the dist directory + const response = await env.ASSETS.fetch(request); + + // Add CORS header for giscus theme CSS + if (url.pathname === '/giscus-theme.css') { + const newHeaders = new Headers(response.headers); + newHeaders.set('Access-Control-Allow-Origin', 'https://giscus.app'); + return new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: newHeaders, + }); + } + + return response; + }, +}; diff --git a/wrangler.toml b/wrangler.toml index 4d2b36d..7917908 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,5 +1,7 @@ name = "codingwithcalvin-net" compatibility_date = "2024-12-01" +main = "src/worker.ts" [assets] directory = "./dist" +binding = "ASSETS"