mw/cors
Cross-origin request handling driven by a CORS_ORIGIN allow-list, for Express, Fastify or Hono.
Provides: middleware:cors
Requires: http, config:env
Dependencies
cors@^2.8.5(whenhas('http/express'))@fastify/cors@^11.1.0(whenhas('http/fastify'))
Development only:
@types/cors@^2.8.19(whenprovides('language:typescript') && has('http/express'))
Environment
| Variable | Required | Description |
|---|---|---|
CORS_ORIGIN | no | Comma-separated list of allowed origins, or * for any |
What it contributes to other files
| File | Slot | Line |
|---|---|---|
src/config/env.ts|js | env-schema | CORS_ORIGIN: z.string().default('*'), |
src/app.ts|js | imports | import { env } from './config/env.js'; |
src/app.ts|js | imports | import cors from 'cors'; |
src/app.ts|js | middleware | app.use( |
src/app.ts|js | imports | import fastifyCors from '@fastify/cors'; |
src/app.ts|js | middleware | await app.register(fastifyCors, { |
src/app.ts|js | imports | import { cors } from 'hono/cors'; |
src/app.ts|js | middleware | app.use( |
Use it
atarashi new my-app --add mw/cors
atarashi add mw/cors
Version 1.0.0. Format reference: Authoring blueprints.
Part of the atarashi documentation, written and maintained by Gautam Suthar.