OptionaloriginsAllowed origins for CORS requests.
// Static origins
origins: 'https://example.com'
origins: ['https://app1.com', 'https://app2.com']
// Dynamic origins with env access
origins: ({ request, env }) => {
const origin = request.headers.get('Origin');
const allowed = env.ALLOWED_ORIGINS?.split(',') || [];
return origin && allowed.includes(origin) ? origin : null;
}
OptionalmethodsAllowed HTTP methods for CORS requests.
OptionalheadersAllowed headers for CORS requests.
OptionalmaxMax age for preflight request caching in seconds.
OptionalcredentialsWhether to allow credentials (cookies, authorization headers). Note: Cannot be true when origins is '*'
Configuration options for CORS behavior