actix-cors

Cross-Origin Resource Sharing (CORS) middleware for the Actix Web framework

Library
Cargo
v0.7.1
887stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
95/100Excellent
Development Activity96
Maintenance100
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture80
Code Quality84
Innovation60
Learning Curve78

actix-cors provides a configurable Cross-Origin Resource Sharing (CORS) middleware for Actix Web, the popular Rust web framework. It handles preflight OPTIONS requests, validates and reflects Origin/Access-Control-* headers according to a builder-configured policy, and supports the experimental Private Network Access draft.

Published from the actix-extras monorepo, which the actix organization maintains alongside actix-web itself as a home for framework-adjacent crates (sessions, identity, rate limiting, HTTP auth, WebSockets). actix-cors is by far the most downloaded crate in that repo, with nearly 19 million total downloads, making it the de facto standard CORS solution for Actix Web applications.

What You Get

  • A Cors middleware constructed via a builder pattern for allowed origins, methods, headers, and credentials
  • Automatic handling of CORS preflight (OPTIONS) requests without writing custom route handlers
  • Permissive (Cors::permissive()) and restrictive builder presets for quick setup versus production lockdown
  • Optional support for the draft Private Network Access header via the draft-private-network-access feature flag
  • Detailed CorsError types surfaced when a request violates the configured policy

Common Use Cases

  • Allowing a separately hosted frontend (SPA on a different origin/port) to call an Actix Web API during development and production
  • Locking down which origins, methods, and headers a public API accepts, rejecting everything else automatically
  • Supporting credentialed cross-origin requests (cookies/auth headers) with explicit origin allow-lists, since wildcard origins can’t be combined with credentials per the CORS spec
  • Quickly unblocking local development with Cors::permissive() before tightening the policy for production

Under The Hood

Architecture - The crate (1,584 lines across src/) separates concerns cleanly: builder.rs implements the fluent configuration API, inner.rs holds the resolved/validated CORS policy used at request time, middleware.rs implements the actual Actix Web Transform/Service that intercepts preflight requests and injects response headers, all_or_some.rs models the allow-list-vs-wildcard duality for origins/headers/methods, and error.rs defines the CorsError variants. Tech Stack - Built directly against actix-web 4’s middleware trait system and actix-utils, using derive_more for error boilerplate, futures-util for async plumbing, and smallvec/once_cell for allocation-conscious header/config storage; part of a Cargo workspace with shared repository/license/edition fields inherited from actix-extras. Code Quality - tests/tests.rs provides integration-level coverage of preflight handling, origin/method/header validation, and credential edge cases, alongside a runnable examples/cors.rs; the crate has shipped over 15 releases since 2020 with an active CI pipeline (GitHub Actions, Codecov) shared across the actix-extras workspace. API Design - The builder API (Cors::default().allowed_origin(...).allowed_methods(...)) mirrors idiomatic Rust builder conventions and Actix Web’s own middleware registration pattern (.wrap()), making it low-friction for anyone already using Actix Web, though correctly reasoning about the CORS spec’s credentials/wildcard interaction still requires the developer to understand CORS semantics, not just the API surface.

Used by 6 apps in this directory

Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
Rust
78%
AGPL 3.0

Lemmy

Community · Social Media

14,555

Federated, self-hosted Reddit alternative with full community ownership and no corporate control.

View details
90
Repo Health
74
Technical
63
Dependency
Built with
Rust78%
PLpgSQL14%
Updated yesterday
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
Rust
89%
Apache 2.0

Qdrant

Databases · AI Development · Search

34,058

Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.

View details
92
Repo Health
87
Technical
69
Dependency
Built with
Rust89%
Updated yesterday
Rust
71%
MIT

Trieve

AI Development · Search · Developer Tools

2,715

All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.

View details
43
Repo Health
74
Technical
66
Dependency
Built with
Rust71%
Updated 6 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search