Skip to content

Commit 543be29

Browse files
committed
api: let the CORs library handle CORs headers
License: MIT Signed-off-by: Steven Allen <[email protected]>
1 parent 821c36c commit 543be29

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/corehttp/commands.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
6767
}
6868
}
6969

70-
c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders))
70+
c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1)
7171

7272
// Copy these because the config is shared and this function is called
7373
// in multiple places concurrently. Updating these in-place *is* racy.
7474
for h, v := range nc.API.HTTPHeaders {
75-
c.Headers[h] = v
75+
switch h {
76+
case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials:
77+
// these are handled by the CORs library.
78+
default:
79+
c.Headers[h] = v
80+
}
7681
}
7782
c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber}
7883
}

0 commit comments

Comments
 (0)