# gin-contrib/cors

Official CORS gin's middleware

Repository: https://github.com/gin-contrib/cors
Canonical: https://ross.abutalabs.com/products/gin-contrib-cors
Homepage: https://gin-gonic.github.io/gin/
Language: Go
License: MIT
License Family: permissive
Last push: 2026-08-24T23:02:40+00:00

## Health v2 (maintenance only)
Score: 87/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 65, longevity 100
- inputs: {"age_days": 3950, "days_push": 9, "days_rel": 158, "gap_med": 79.0, "n_releases_24m": 5}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1999, forks 188 (observed 2026-08-28T04:06:03.753706+00:00)

## What it is
The official CORS (Cross-Origin Resource Sharing) middleware for the Gin web framework in Go. It provides configurable handling of allowed origins, methods, headers, credentials, and preflight caching for Gin-based HTTP APIs.

## Use cases
- enable CORS on a Gin API server
- allow requests from a specific frontend origin
- handle preflight OPTIONS requests in Go
- configure credentialed cross-origin requests
- restrict allowed HTTP methods and headers cross-origin
- add CORS headers to a REST API written in Go

## When to choose
- you use the Gin framework and need CORS support
- you want a small, well-maintained, configurable CORS middleware
- you need custom origin validation logic in Go

## When to avoid
- your server does not use Gin
- you need CORS for a non-Go stack
- you need a general-purpose HTTP middleware framework rather than CORS specifically

## Facets
- artifact type: library
- maturity: stable
- function: middleware, http-server, security, web-framework
- domain: web-development, backend, apis, security
- platform: go, windows, cross-platform
- tags: cors, gin, cross-origin-resource-sharing, http-middleware, api-security, linux, macos

## Member repositories
- gin-contrib/cors (main) score 87

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:03.753706+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:02:10.353512+00:00, confidence not recorded.
  - readme: https://github.com/gin-contrib/cors (fetched 2026-08-28T04:06:03.753706+00:00, sha cb571eec5417)
- Data as of 2026-08-30T08:39:29.467469+00:00.
