Skip to content

Commit baf70c2

Browse files
authored
Merge pull request #772 from 0xPolygon/udpate-wrangler-pattern-deployment
fix(NO-JIRA): serve listRegistry.json at root
2 parents 4b66ca2 + 6f34898 commit baf70c2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import listRegistry from "../build/listRegistry.json";
2+
3+
const corsHeaders = {
4+
"Access-Control-Allow-Origin": "*",
5+
"Access-Control-Allow-Methods": "GET, HEAD, POST, OPTIONS",
6+
"Access-Control-Allow-Headers": "Content-Type",
7+
};
8+
9+
export default {
10+
async fetch(request) {
11+
const url = new URL(request.url);
12+
13+
if (request.method === "OPTIONS") {
14+
return new Response(null, { headers: corsHeaders });
15+
}
16+
17+
if (url.pathname === "/") {
18+
const json = JSON.stringify(listRegistry, null, 2);
19+
return new Response(json, {
20+
headers: {
21+
"content-type": "application/json;charset=UTF-8",
22+
...corsHeaders,
23+
},
24+
});
25+
}
26+
return new Response("Not Found", { status: 404 });
27+
},
28+
};
29+

0 commit comments

Comments
 (0)