Koa2 CORS Middleware

JSON →
library 2.0.6 ·javascript
verified May 27, 2026

koa2-cors is a Koa 2.x middleware for handling Cross-Origin Resource Sharing (CORS) headers. It simplifies the implementation of CORS policies in Koa applications, allowing developers to configure the `Access-Control-Allow-Origin`, `Access-Control-Expose-Headers`, `Access-Control-Max-Age`, `Access-Control-Allow-Credentials`, `Access-Control-Allow-Methods`, and `Access-Control-Allow-Headers` through a straightforward options object or a dynamic function for the origin. The current stable version is 2.0.6. The package has seen sporadic updates, with recent releases focusing on compatibility (e.g., removing Babel in v2.0.5) and ensuring correct header behavior (v2.0.6 always sets `Vary: Origin`). It requires Node.js v7.6.0 or higher. Its key differentiator is its direct integration and simplicity within the Koa 2.x ecosystem, providing a robust and easy-to-configure solution for common CORS requirements without over-complication.

total hits 15
actors 6 distinct systems
last hit 22h ago AhrefsBot
MetaBot
4
GPTBot
2
Script
1
Search engines
1
Humans
2

top countries 🇺🇸 United States · 🇳🇴 Norway · 🇨🇦 Canada · 🇩🇪 Germany · 🇫🇷 France