On GitHub, rs/cors has picked up 2.9k stars, Go. Go net/http configurable handler to handle CORS requests
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This library has been modified to avoid a well known security issue when configured with AllowedOrigins to * and AllowCredentials to true. Such setup used to make the library reflects the request Origin header value, working around a security protection embedded into the standard that makes clients to refuse such configuration. This behavior has been removed with #55 and #57.
If you depend on this behavior and understand the implications, you can restore it using the AllowOriginFunc with func(origin string) {return true}.
Please refer to #55 for more information about the security implications.
More Examples
net/http: examples/nethttp/server.go
Goji: examples/goji/server.go
Martini: examples/martini/server.go
Negroni: examples/negroni/server.go
Alice: examples/alice/server.go
HttpRouter: examples/httprouter/server.go
Gorilla: examples/gorilla/server.go
Buffalo: examples/buffalo/server.go
Gin: examples/gin/server.go
Chi: examples/chi/server.go
Parameters
Parameters are passed to the middleware thru the cors.New method as follow:
c := cors.New(cors.Options{
AllowedOrigins: []string{"http://foo.com", "http://foo.com:8080"},
AllowCredentials: true,
// Enable Debugging for testing, consider disabling in production
Debug: true,
})
// Insert the middleware
handler = c.Handler(handler)
AllowedOrigins[]string: A list of origins a cross-domain request can be executed from. If the special * value is present in the list, all origins will be allowed. An origin may contain a wildcard (*) to replace 0 or more characters (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penality. Only one wildcard can be used per origin. The default value is *.
AllowOriginFuncfunc (origin string) bool: A custom function to validate the origin. It takes the origin as an argument and returns true if allowed, or false otherwise. If this option is set, the content of AllowedOrigins is ignored.
AllowOriginRequestFuncfunc (r *http.Request, origin string) bool: A custom function to validate the origin. It takes the HTTP Request object and the origin as argument and returns true if allowed or false otherwise. If this option is set, the contents of AllowedOrigins and AllowOriginFunc are ignored.
Deprecated: use AllowOriginVaryRequestFunc instead.
AllowOriginVaryRequestFuncfunc(r *http.Request, origin string) (bool, []string): A custom function to validate the origin. It takes the HTTP Request object and the origin as argument and returns true if allowed or false otherwise with a list of headers used to take that decision if any so they can be added to the Vary header. If this option is set, the contents of AllowedOrigins, AllowOriginFunc and AllowOriginRequestFunc are ignored.
AllowedMethods[]string: A list of methods the client is allowed to use with cross-domain requests. Default value is simple methods (GET and POST).
AllowedHeaders[]string: A list of non simple headers the client is allowed to use with cross-domain requests.
ExposedHeaders[]string: Indicates which headers are safe to expose to the API of a CORS API specification.
AllowCredentialsbool: Indicates whether the request can include user credentials like cookies, HTTP authentication or client side SSL certificates. The default is false.
AllowPrivateNetworkbool: Indicates whether to accept cross-origin requests over a private network.
MaxAgeint: Indicates how long (in seconds) the results of a preflight request can be cached. The default is 0 which stands for no max age.
OptionsPassthroughbool: Instructs preflight to let other potential next handlers to process the OPTIONS method. Turn this on if your application handles OPTIONS.
OptionsSuccessStatusint: Provides a status code to use for successful OPTIONS requests. Default value is http.StatusNoContent (204).
Debugbool: Debugging flag adds additional output to debug server side CORS issues.
The most recent commit recorded on rs/cors was 18 days ago, based on the GitHub push timestamp. The repository has 241 forks — one of the better signals of community interest.
How many stars does rs/cors have?
rs/cors has 2.9k GitHub stars — refresh the page for the live number, or check github.com/rs/cors. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is rs/cors open source?
Yes — rs/cors ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/rs/cors.
What is rs/cors?
rs/cors (rs/cors) is a Go project on GitHub. From the project's own README: Go net/http configurable handler to handle CORS requests
What language is rs/cors written in?
rs/cors is written primarily in Go. GitHub's language field is based on the largest share of bytes in the default branch.
What license does rs/cors use?
rs/cors is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about rs/cors?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/rs/cors is the definitive source.
Read full README in the tab above.
Curious whether cors is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about cors.