mirror of
https://github.com/Luzifer/ots.git
synced 2025-09-26 11:01:05 -04:00
Make CORS handling configurable
Signed-off-by: Quincy Mast <email.quincymast@gmail.com>
This commit is contained in:
parent
1b29e6ae8f
commit
1e3d10c1ae
2 changed files with 9 additions and 5 deletions
13
api.go
13
api.go
|
@ -56,11 +56,14 @@ func (a apiServer) Register(r *mux.Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {
|
func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {
|
||||||
res.Header().Set("Access-Control-Allow-Origin", "*")
|
if cust.AddCORSHeaders {
|
||||||
res.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
|
res.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
if r.Method == http.MethodOptions {
|
res.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
|
||||||
res.WriteHeader(http.StatusNoContent)
|
if r.Method == http.MethodOptions {
|
||||||
return
|
res.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cust.MaxSecretSize > 0 {
|
if cust.MaxSecretSize > 0 {
|
||||||
|
|
|
@ -41,6 +41,7 @@ type (
|
||||||
MetricsAllowedSubnets []string `json:"-" yaml:"metricsAllowedSubnets"`
|
MetricsAllowedSubnets []string `json:"-" yaml:"metricsAllowedSubnets"`
|
||||||
OverlayFSPath string `json:"-" yaml:"overlayFSPath"`
|
OverlayFSPath string `json:"-" yaml:"overlayFSPath"`
|
||||||
UseFormalLanguage bool `json:"-" yaml:"useFormalLanguage"`
|
UseFormalLanguage bool `json:"-" yaml:"useFormalLanguage"`
|
||||||
|
AddCORSHeaders bool `json:"-" yaml:"addCORSHeaders"`
|
||||||
|
|
||||||
FooterLinks []FooterLink `json:"footerLinks,omitempty" yaml:"footerLinks"`
|
FooterLinks []FooterLink `json:"footerLinks,omitempty" yaml:"footerLinks"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue