Spaces:
Sleeping
Sleeping
Download src/middleware/cors.js from jackchen75/dusttt2api: direct link, hf CLI and curl.
- Browser
- Download file 474 Bytes
-
https://huggingface.co/spaces/jackchen75/dusttt2api/resolve/main/src/middleware/cors.js
- Command line
-
hf download hf://spaces/jackchen75/dusttt2api/src/middleware/cors.js
-
curl -L -o cors.js https://huggingface.co/spaces/jackchen75/dusttt2api/resolve/main/src/middleware/cors.js
474 Bytes
| /** | |
| * CORS 中间件 | |
| */ | |
| export const corsMiddleware = (event) => { | |
| // 设置 CORS 头 | |
| event.res.headers.set('Access-Control-Allow-Origin', '*'); | |
| event.res.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); | |
| event.res.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization'); | |
| event.res.headers.set('Access-Control-Max-Age', '86400'); | |
| // 处理预检请求 | |
| if (event.method === 'OPTIONS') { | |
| return ''; | |
| } | |
| }; | |