aiohttp-cors
CORS support for aiohttp
What it is and what it does
aiohttp_cors is a middleware library that implements the CORS standard for aiohttp, an async HTTP server framework. It solves the problem of allowing web browsers to make cross-origin requests to your server by handling the browser's same-origin policy restrictions through proper HTTP headers and preflight request handling. The library lets you configure which origins can access specific routes, whether credentials are allowed, which headers clients can send, and which headers the server exposes back to clients.
You configure CORS per route by wrapping resources and routes through the library's API, specifying allowed origins and their associated options. The package handles both simple requests (which include the Origin header) and preflight requests (OPTIONS method queries that browsers send before complex requests). It supports wildcard origins for permissive configurations and per-origin customization for fine-grained control.
Use it for:
- Enable a single-page application served from a different domain to make API calls to your aiohttp server.
- Allow mobile apps or desktop clients to access your async HTTP API without browser same-origin restrictions.
- Configure different CORS policies for different routes—strict for sensitive endpoints, permissive for public APIs.
- Handle preflight caching to reduce browser OPTIONS requests and improve client-side performance.
- Expose custom response headers to browser clients while controlling which request headers are accepted.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds Cross-Origin Resource Sharing (CORS) support to aiohttp applications, enabling controlled cross-origin HTTP requests from browsers by configuring which origins can access specific routes and what credentials and headers are allowed.
Yes, if you are building an aiohttp application that needs to serve cross-origin requests from browsers. The package has low install friction, active maintenance, permissive licensing, and no known vulnerabilities. The Alpha status reflects the library's maturity rather than instability—it has been in use since 2015. Install it when you need CORS support; skip it if your API is same-origin only or uses alternative cross-origin strategies.
Install
aiohttp-cors on PyPI
pip
pip install aiohttp-corsuv
uv add aiohttp-corspoetry
poetry add aiohttp-corsInstalling aiohttp-cors
Before you install
Low install friction with a single runtime dependency on aiohttp. The package is actively maintained with a recent release in March 2025 and ongoing repository activity, though classified as Alpha development status.
License in practice
Licensed under Apache License 2.0 (permissive), allowing commercial and private use with minimal restrictions—suitable for most projects that can accommodate attribution.
Quickstart
pip install aiohttp-cors
import aiohttp_cors
from aiohttp import web
app = web.Application()
cors = aiohttp_cors.setup(app)
resource = cors.add(app.router.add_resource("/hello"))
cors.add(resource.add_route("GET", handler), {
"http://client.example.org": aiohttp_cors.ResourceOptions(
allow_credentials=True,
expose_headers=("X-Custom-Server-Header",),
)
})
Requires Python 3.9 or later and an existing aiohttp application to configure.
Verify before relying
- Whether the Alpha development status reflects active feature development or stable maintenance with conservative versioning.
- Performance characteristics when handling high volumes of preflight requests or complex CORS configurations.
Package facts
| License | Apache License, Version 2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — aiohttp |
| Maintenance | actively maintained — 501 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 19,173,377/month — #1,072 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aiohttp_cors-0.8.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
aiohttp-middlewaresProvides a collection of ready-to-use…
permissive · top 15,000 on PyPI
django-cors-headersAdds Cross-Origin Resource Sharing (CORS)…
permissive · top 1,000 on PyPI
fastapi-corsConfigures CORS settings for FastAPI…
permissive · top 15,000 on PyPI
quart-corsQuart-CORS adds Cross-Origin Resource Sharing…
permissive · top 15,000 on PyPI
cherrypy-corsAdds Cross-Origin Resource Sharing (CORS)…
permissive · top 15,000 on PyPI
flask-corsFlask-CORS handles Cross-Origin Resource…
permissive · top 1,000 on PyPI
Sanic-CorsSanic-CORS is a Sanic extension that adds…
permissive · top 15,000 on PyPI
invenio-restInvenio-REST provides Flask-based REST API…
permissive · top 15,000 on PyPI
aiohttp-basicauthProvides HTTP basic authentication middleware…
permissive · top 15,000 on PyPI
aiohttp-swagger3Integrates OpenAPI 3 documentation and request…
permissive · top 15,000 on PyPI