mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
This commit is contained in:
parent
7dc0c6ab43
commit
4d1bcd718c
@ -302,7 +302,7 @@ func (s *service) serve(ctx context.Context) {
|
|||||||
mut: sync.NewMutex(),
|
mut: sync.NewMutex(),
|
||||||
}
|
}
|
||||||
|
|
||||||
configBuilder.registerConfig("/rest/config/")
|
configBuilder.registerConfig("/rest/config")
|
||||||
configBuilder.registerConfigInsync("/rest/config/insync")
|
configBuilder.registerConfigInsync("/rest/config/insync")
|
||||||
configBuilder.registerFolders("/rest/config/folders")
|
configBuilder.registerFolders("/rest/config/folders")
|
||||||
configBuilder.registerDevices("/rest/config/devices")
|
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
|
// Add a generous access-control-allow-origin header for CORS requests
|
||||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
// Only GET/POST/OPTIONS Methods are supported
|
// 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
|
// Only these headers can be set
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, X-API-Key")
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, X-API-Key")
|
||||||
// The request is meant to be cached 10 minutes
|
// The request is meant to be cached 10 minutes
|
||||||
|
@ -403,6 +403,12 @@ func TestAPIServiceRequests(t *testing.T) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// /rest/config
|
// /rest/config
|
||||||
|
{
|
||||||
|
URL: "/rest/config",
|
||||||
|
Code: 200,
|
||||||
|
Type: "application/json",
|
||||||
|
Prefix: "",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
URL: "/rest/config/folders",
|
URL: "/rest/config/folders",
|
||||||
Code: 200,
|
Code: 200,
|
||||||
@ -1073,8 +1079,8 @@ func TestOptionsRequest(t *testing.T) {
|
|||||||
if resp.Header.Get("Access-Control-Allow-Origin") != "*" {
|
if resp.Header.Get("Access-Control-Allow-Origin") != "*" {
|
||||||
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Origin: *' header")
|
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Origin: *' header")
|
||||||
}
|
}
|
||||||
if resp.Header.Get("Access-Control-Allow-Methods") != "GET, POST, OPTIONS" {
|
if resp.Header.Get("Access-Control-Allow-Methods") != "GET, POST, PUT, PATCH, DELETE, OPTIONS" {
|
||||||
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Methods: GET, POST, OPTIONS' header")
|
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS' header")
|
||||||
}
|
}
|
||||||
if resp.Header.Get("Access-Control-Allow-Headers") != "Content-Type, X-API-Key" {
|
if resp.Header.Get("Access-Control-Allow-Headers") != "Content-Type, X-API-Key" {
|
||||||
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Headers: Content-Type, X-API-KEY' header")
|
t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Headers: Content-Type, X-API-KEY' header")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user