lib/api: Fix /rest/config path and add methods to cors (ref #7001) (#7081)

This commit is contained in:
Simon Frei
2020-11-01 21:36:54 +01:00
committed by GitHub
parent 7dc0c6ab43
commit 4d1bcd718c
2 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -302,7 +302,7 @@ func (s *service) serve(ctx context.Context) {
mut: sync.NewMutex(),
}
configBuilder.registerConfig("/rest/config/")
configBuilder.registerConfig("/rest/config")
configBuilder.registerConfigInsync("/rest/config/insync")
configBuilder.registerFolders("/rest/config/folders")
configBuilder.registerDevices("/rest/config/devices")
@@ -504,7 +504,7 @@ func corsMiddleware(next http.Handler, allowFrameLoading bool) http.Handler {
// Add a generous access-control-allow-origin header for CORS requests
w.Header().Add("Access-Control-Allow-Origin", "*")
// Only GET/POST/OPTIONS Methods are supported
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS")
// Only these headers can be set
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, X-API-Key")
// The request is meant to be cached 10 minutes