skillfed

aiohttp-cors

CORS support for aiohttp

aiohttp-cors v0.8.1 19.2M downloads/30d#1,072 on PyPI220
Permissive license Apache License, Version 2.0 Active released

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-cors

uv

uv add aiohttp-cors

poetry

poetry add aiohttp-cors

Installing 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

Development Status :: 3 - AlphaFramework :: AsyncIOFramework :: aiohttpIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries

Tags

aiohttp cors middlewarecross-origin resource sharing asyncbrowser cors headers aiohttpaiohttp preflight requestscors configuration aiohttp routessame-origin policy overrideaiohttp access control headers
async-httpbrowser-securitymiddleware

More Libraries packages