mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-06-05 23:51:39 +08:00
feat: add page functions proxy to make response faster (#234)
This commit is contained in:
9
pages/functions/_middleware.js
Normal file
9
pages/functions/_middleware.js
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user