/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-environment-depende-18872da82b15-environment-dependent-cors-configuration-s0195-c0000.md
Environment-dependent CORS configuration - hono-docs
Environment dependent CORS configuration Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt environm...
Environment-dependent CORS configuration
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#environment-dependent-cors-configuration
Summary
If you want to adjust CORS configuration according to the execution environment, such as development or production, injecting values from environment variables is convenient as it eliminates the need for the application to be aware of it...
Content
If you want to adjust CORS configuration according to the execution environment, such as development or production, injecting values from environment variables is convenient as it eliminates the need for the application to be aware of its own execution environment. See the example below for clarification.
app.use('*', async (c, next) => {
const corsMiddlewareHandler = cors({
origin: c.env.CORS_ORIGIN,
})
return corsMiddlewareHandler(c, next)
})