mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-05-04 19:06:24 +00:00
22 lines
696 B
JavaScript
22 lines
696 B
JavaScript
import { errorHandling, telemetryData, checkDatabaseConfig } from '../utils/middleware';
|
|
|
|
// CORS 跨域响应头
|
|
const corsHeaders = {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
'Access-Control-Max-Age': '86400',
|
|
};
|
|
|
|
// OPTIONS 预检请求处理
|
|
async function handleOptions(context) {
|
|
if (context.request.method === 'OPTIONS') {
|
|
return new Response(null, {
|
|
status: 204,
|
|
headers: corsHeaders
|
|
});
|
|
}
|
|
return context.next();
|
|
}
|
|
|
|
export const onRequest = [checkDatabaseConfig, handleOptions, errorHandling, telemetryData]; |