feat: add page functions proxy to make response faster (#234)

This commit is contained in:
Dream Hunter
2024-05-14 12:43:03 +08:00
committed by GitHub
parent 9de2d23be1
commit ea4ce9bf63
8 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
const API_PATHS = ["/api/", "/open_api/", "/user_api/", "/admin/"]
export async function onRequest(context) {
const reqPath = new URL(context.request.url).pathname;
if (API_PATHS.map(path => reqPath.startsWith(path)).some(Boolean)) {
return context.env.BACKEND.fetch(context.request);
}
return await context.next();
}