Blog

koa-cors and @koa/cors: async middleware stacks, delegated methods, and origin checks with downstream routers

Koa’s onion model means CORS middleware wraps later layers—ensure ctx.set headers survive after await next().

1 min read
koacorsnodejs

Streaming bodies

When streaming uploads, respond to OPTIONS before consuming the stream or clients may see timeouts disguised as CORS failures.

Server-sent events need explicit flushing of CORS headers on initial 200 responses.

Testing

Use supertest with Origin headers in every integration test matrix entry.

Snapshot koa-cors defaults after upgrades—minor semver releases can widen allowed methods.

Back to blog