rs/cors hiện có 2.9k sao trên GitHub, viết chủ yếu bằng Go. Go net/http configurable handler to handle CORS requests
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/rs/cors là nguồn chính thức.
rs/cors có bao nhiêu sao?
rs/cors có 2.9k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/rs/cors. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
rs/cors có phải mã nguồn mở không?
Có — rs/cors phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/rs/cors.
rs/cors còn đang phát triển không?
Commit gần nhất trên rs/cors là 18 ngày trước (theo timestamp GitHub). Repo có 241 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
rs/cors dùng license gì?
rs/cors phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
rs/cors là gì?
rs/cors (rs/cors) là dự án Go trên GitHub. Theo mô tả gốc: Go net/http configurable handler to handle CORS requests
rs/cors viết bằng ngôn ngữ gì?
rs/cors chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc cors có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về cors.