Closed grtfou closed 5 years ago
I try the sample code
func main() { r := chi.NewRouter() // Basic CORS cors := cors.New(cors.Options{ AllowedOrigins: []string{"https://foo.com"}, AllowedMethods: []string{"POST", "OPTIONS"}, AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, ExposedHeaders: []string{"Link"}, AllowCredentials: true, MaxAge: 300, }) r.Use(cors.Handler) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("welcome")) }) http.ListenAndServe("127.0.0.1:3000", r) }
$ curl -H "Origin: http://example.com" http://localhost:3000/ welcome # ?
Doesn't any setting I lost?
Thank you. :)
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
I try the sample code
Doesn't any setting I lost?
Thank you. :)