Skip to content

Commit 0e9a41b

Browse files
authored
feat: serve website via Worker static assets (#57)
1 parent 356b475 commit 0e9a41b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

worker/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { handleAutocomplete, handleCommand } from "./handlers.ts";
88
import { verifyRequest } from "./verify.ts";
99

1010
interface Env {
11+
ASSETS: Fetcher;
1112
DISCORD_PUBLIC_KEY: string;
1213
DISCORD_APPLICATION_ID: string;
1314
DISCORD_BOT_TOKEN: string;
@@ -17,7 +18,7 @@ interface Env {
1718
export default {
1819
async fetch(request: Request, env: Env): Promise<Response> {
1920
if (request.method !== "POST") {
20-
return new Response("Method Not Allowed", { status: 405 });
21+
return env.ASSETS.fetch(request);
2122
}
2223

2324
const signature = request.headers.get("X-Signature-Ed25519");

worker/wrangler.jsonc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
"name": "coffee",
33
"main": "src/index.ts",
44
"compatibility_date": "2025-02-03",
5+
"assets": {
6+
"directory": "../site/dist",
7+
"binding": "ASSETS",
8+
"html_handling": "auto-trailing-slash",
9+
"not_found_handling": "404-page",
10+
"run_worker_first": true
11+
},
512
"vars": {
613
"DISCORD_PUBLIC_KEY": "48f59590c72e1076554a99adeeb47eb678c87b92202b18cfea1b03ce5dbcbf02",
714
"DISCORD_APPLICATION_ID": "1464984307331502092",

0 commit comments

Comments
 (0)