1
0
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2025-07-02 04:39:23 +00:00

Enhance CORS configuration in app.js to support path-based options and set max age for preflight requests. Update dependencies in package.json and pnpm-lock.yaml to latest versions, including express, body-parser, http-errors, and morgan.

This commit is contained in:
SunWuyuan 2025-05-11 11:35:08 +08:00
parent 6897a082e7
commit 4a8b19c0b8
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64
3 changed files with 214 additions and 669 deletions

3
app.js
View File

@ -20,10 +20,11 @@ import kvRouter from "./routes/kv.js";
var app = express(); var app = express();
import cors from "cors"; import cors from "cors";
app.options("*", cors()); app.options("/{*path}", cors());
app.use( app.use(
cors({ cors({
exposedHeaders: ["ratelimit-policy", "retry-after", "ratelimit"], // 告诉浏览器这些响应头可以暴露 exposedHeaders: ["ratelimit-policy", "retry-after", "ratelimit"], // 告诉浏览器这些响应头可以暴露
maxAge: 86400, // 设置OPTIONS请求的结果缓存24小时(86400秒),减少预检请求
}) })
); );
app.disable("x-powered-by"); app.disable("x-powered-by");

View File

@ -23,16 +23,16 @@
"@opentelemetry/semantic-conventions": "^1.33.0", "@opentelemetry/semantic-conventions": "^1.33.0",
"@prisma/client": "6.7.0", "@prisma/client": "6.7.0",
"axios": "^1.9.0", "axios": "^1.9.0",
"body-parser": "^1.20.3", "body-parser": "^2.2.0",
"cookie-parser": "~1.4.4", "cookie-parser": "~1.4.4",
"cors": "^2.8.5", "cors": "^2.8.5",
"debug": "~2.6.9", "debug": "~4.4.0",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"ejs": "^3.1.10", "ejs": "^3.1.10",
"express": "~4.16.1", "express": "~5.1.0",
"express-rate-limit": "^7.5.0", "express-rate-limit": "^7.5.0",
"http-errors": "~1.6.3", "http-errors": "~2.0.0",
"morgan": "~1.9.1", "morgan": "~1.10.0",
"uuid": "^11.1.0" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {

870
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff