Skip to content

Commit

Permalink
Merge pull request #816 from replicatedhq/laverya/redact-enabled-cors
Browse files Browse the repository at this point in the history
respond to OPTIONS requests on /api/v1/redact/enabled/{slug}
  • Loading branch information
laverya committed Jul 20, 2020
2 parents db19fa0 + 9c794f6 commit 69664c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kotsadm/pkg/apiserver/server.go
Expand Up @@ -80,7 +80,7 @@ func Start() {
r.Path("/api/v1/redact/spec/{slug}").Methods("OPTIONS", "GET").HandlerFunc(handlers.GetRedactMetadataAndYaml)
r.Path("/api/v1/redact/spec/{slug}").Methods("POST").HandlerFunc(handlers.SetRedactMetadataAndYaml)
r.Path("/api/v1/redact/spec/{slug}").Methods("DELETE").HandlerFunc(handlers.DeleteRedact)
r.Path("/api/v1/redact/enabled/{slug}").Methods("POST").HandlerFunc(handlers.SetRedactEnabled)
r.Path("/api/v1/redact/enabled/{slug}").Methods("OPTIONS", "POST").HandlerFunc(handlers.SetRedactEnabled)

r.PathPrefix("/api/v1/kots/").Methods("OPTIONS").HandlerFunc(handlers.CORS)
r.PathPrefix("/api/v1/kots/").Methods("HEAD", "GET", "POST", "PUT", "DELETE").HandlerFunc(handlers.NodeProxy(upstream))
Expand Down
5 changes: 5 additions & 0 deletions kotsadm/pkg/handlers/redact.go
Expand Up @@ -353,6 +353,11 @@ func SetRedactEnabled(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", "content-type, origin, accept, authorization")

if r.Method == "OPTIONS" {
w.WriteHeader(200)
return
}

metadataResponse := GetRedactorResponse{
Success: false,
}
Expand Down

0 comments on commit 69664c3

Please sign in to comment.