Access-Control-Allow-Headers is apparently required by the spec

This commit is contained in:
Kilowhisky 2024-05-06 22:07:07 -07:00
parent e653b765b7
commit 1a437d3855
2 changed files with 8 additions and 3 deletions

View File

@ -1450,9 +1450,10 @@ func readNextHTTPCommand(packet []byte, argsIn [][]byte, msg *Message, wr io.Wri
if wr == nil {
return false, errors.New("connection is nil")
}
corshead := "HTTP/1.1 204 No Content\r\n"+
"Connection: close\r\n"+
"Access-Control-Allow-Origin: *\r\n"+
corshead := "HTTP/1.1 204 No Content\r\n" +
"Connection: close\r\n" +
"Access-Control-Allow-Origin: *\r\n" +
"Access-Control-Allow-Headers: *, Authorization\r\n" +
"Access-Control-Allow-Methods: POST, GET, OPTIONS\r\n\r\n"
if _, err = wr.Write([]byte(corshead)); err != nil {

View File

@ -31,12 +31,16 @@ func proto_HTTP_CORS_test(mc *mockServer) error {
}
origin := resp.Header.Get("Access-Control-Allow-Origin")
methods := resp.Header.Get("Access-Control-Allow-Methods")
headers := resp.Header.Get("Access-Control-Allow-Headers")
if !(origin == "*" || origin == morigin) {
return fmt.Errorf("expected http access-control-allow-origin value '*', got '%s'", origin)
}
if methods != "POST, GET, OPTIONS" {
return fmt.Errorf("expected http access-control-allow-Methods value 'POST, GET, OPTIONS', got '%s'", methods)
}
if headers != "*, Authorization" {
return fmt.Errorf("expected http access-control-allow-headers value '*, Authorization', got '%s'", headers)
}
// Make the actual request now
resp, err = http.Get(url)