skillfed

fastapi-cors

Simple env support of CORS settings for Fastapi applications

fastapi-cors v0.0.6 240.6K downloads/30d#8,904 on PyPI
Permissive license MIT Abandoned released

What it is and what it does

fastapi-cors is a thin wrapper around FastAPI's built-in CORS middleware that reads configuration from environment variables instead of requiring programmatic setup. It lets you define allowed origins, methods, headers, and credential support through a .env file, then applies those settings with a single function call. The package includes an optional health-check route that displays the active CORS environment variables.

The package is designed for developers who want to manage CORS policy through environment configuration rather than code. It depends on environs to parse and cast environment variables, and fastapi as its target framework. Since the package is abandoned (no updates since July 2023), it receives no maintenance or security updates, making it suitable only for stable, low-risk deployments or as a reference implementation rather than a production dependency.

Use it for:

  • Configure CORS for a FastAPI app using only environment variables, avoiding hardcoded origin lists in code.
  • Set different CORS policies across development, staging, and production by changing .env files without code changes.
  • Add a health-check endpoint that reports the active CORS configuration for debugging cross-origin request issues.
  • Quickly scaffold a FastAPI app with sensible CORS defaults (localhost and localhost:3000 allowed) for local development.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Configures CORS settings for FastAPI applications via environment variables, with optional health-check endpoint.

No. The package is abandoned and receives no maintenance. For new projects, use FastAPI's built-in CORSMiddleware directly with environment variable parsing via environs or python-dotenv—you gain the same functionality with active upstream support. For existing projects already using fastapi-cors, migration is straightforward since the underlying FastAPI CORS API is stable.

Install

fastapi-cors on PyPI

pip

pip install fastapi-cors

uv

uv add fastapi-cors

poetry

poetry add fastapi-cors

Installing fastapi-cors

Before you install

Low install friction with only two runtime dependencies (environs and fastapi). However, the package is abandoned—last release was 2023-07-12 with no updates since, so expect no maintenance or security patches going forward.

License in practice

MIT license is permissive, allowing commercial and private use with minimal restrictions.

Quickstart

pip install fastapi-cors

from fastapi import FastAPI
from fastapi_cors import CORS

app = FastAPI()
CORS(app)

Requires fastapi and environs as runtime dependencies; reads .env file during import.

Verify before relying

  • Whether the package's defaults (localhost:3000 origins, all methods, credentials enabled) are suitable for production use cases beyond development.
  • How the health-check endpoint behaves when CORS restrictions are in place and whether it poses any security concerns.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — environs, fastapi
Maintenance abandoned — 1,129 days since the last release
First released
Downloads 240,558/month — #8,904 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fastapi_cors-0.0.6-py3-none-any.whl

Environment :: Web EnvironmentFramework :: FastAPIIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: InternetTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: HTTP ServersTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Application FrameworksTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

fastapi cors environment variablescors configuration fastapicross-origin requests fastapifastapi cors setupenv-based cors settingsfastapi cors middleware
corsenvironment-config

More Software Development packages