diff options
author | Boaz Shuster <boaz.shuster.github@gmail.com> | 2021-06-02 23:32:58 +0300 |
---|---|---|
committer | Boaz Shuster <boaz.shuster.github@gmail.com> | 2021-06-04 16:14:52 +0300 |
commit | 2810c478a7f2497fad1300ce63c8476bb50a6ad0 (patch) | |
tree | 98ec1d04e4755d16ac92cc3f3c0071be1e01b80f /pkg/api/server/handler_api.go | |
parent | b64e20a53d3f5de262f2c475be490b35977d5f32 (diff) | |
download | podman-2810c478a7f2497fad1300ce63c8476bb50a6ad0.tar.gz podman-2810c478a7f2497fad1300ce63c8476bb50a6ad0.tar.bz2 podman-2810c478a7f2497fad1300ce63c8476bb50a6ad0.zip |
Add CORS support
[NO TESTS NEEDED]
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
Diffstat (limited to 'pkg/api/server/handler_api.go')
-rw-r--r-- | pkg/api/server/handler_api.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/api/server/handler_api.go b/pkg/api/server/handler_api.go index 28b8706a8..becc674c0 100644 --- a/pkg/api/server/handler_api.go +++ b/pkg/api/server/handler_api.go @@ -63,6 +63,12 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc { w.Header().Set("Libpod-API-Version", lv) w.Header().Set("Server", "Libpod/"+lv+" ("+runtime.GOOS+")") + if s.CorsHeaders != "" { + w.Header().Set("Access-Control-Allow-Origin", s.CorsHeaders) + w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth, Connection, Upgrade, X-Registry-Config") + w.Header().Set("Access-Control-Allow-Methods", "HEAD, GET, POST, DELETE, PUT, OPTIONS") + } + h(w, r) logrus.Debugf("APIHandler(%s) -- %s %s END", rid, r.Method, r.URL.String()) } |