回退edgeone相关修改并修复edgeone 405问题 (#251)

* Revert "修复 EdgeOne token 路由 match 405 (#248)"

This reverts commit e29c9848bc.

* 修复edgeone 405问题
This commit is contained in:
huangxd- authored and GitHub committed 2026-03-21 00:41:07 +08:00
1 parent 33a0a37831
commit c8b42221aa
5 files changed
+20 -24

No files matched your search

+12 -2
View File
@@ -1,4 +1,14 @@
{
"name": "danmu-api",
"outputDirectory": "./"
}
"outputDirectory": "./",
"rewrites": [
{
"source": "/",
"destination": "/node-functions/index.js"
},
{
"source": "/*",
"destination": "/node-functions/[[...path]].js"
}
]
}
+8
View File
@@ -0,0 +1,8 @@
import { onRequest } from './index.js'; // 改为 onRequest,支持所有方法
export const onRequestGet = onRequest;
export const onRequestPost = onRequest;
export const onRequestPut = onRequest;
export const onRequestPatch = onRequest;
export const onRequestDelete = onRequest;
export { onRequest }; // 复用 index.js 的 onRequest
@@ -1,3 +0,0 @@
import { onApiRequest } from '../../api-handler.js';
export const onRequest = onApiRequest;
-16
View File
@@ -1,16 +0,0 @@
import { handleRequest } from '../danmu_api/worker.js';
function getClientIp(request) {
const eoIp = request.headers?.get?.('eo-connecting-ip');
if (eoIp) return eoIp;
const forwardedFor = request.headers?.get?.('x-forwarded-for');
if (forwardedFor) return forwardedFor.split(',')[0].trim();
return 'unknown';
}
export async function onApiRequest(context) {
const { request, env } = context;
return handleRequest(request, env, 'edgeone', getClientIp(request));
}
-3
View File
@@ -1,3 +0,0 @@
import { onApiRequest } from '../api-handler.js';
export const onRequest = onApiRequest;