Skip to content

Conversation

@zlylong
Copy link

@zlylong zlylong commented Feb 9, 2026

Motivation
Make CORS policy explicit and configurable so frontend origin changes can be updated from environment/wrangler config rather than hardcoded *.
Ensure sensible defaults for credentials, request/response headers and to reduce unsafe open CORS settings.
Description
Replace the global cors() call with an env-driven allowlist implementation in mail-worker/src/hono/hono.js that parses c.env values and normalizes origins via normalizeOrigin and parseCorsOrigins functions.
Configure the middleware origin callback to only return an allowed origin from env, and set credentials: false, allowHeaders: ['Authorization', 'Content-Type'], and exposeHeaders: ['Content-Disposition'] in the cors options.
Document a cors_origins example variable in mail-worker/wrangler.toml (commented) so deployers can supply allowed frontend domains (e.g. `[

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant