Skip to content

Commit

Permalink
fix missing CORS headers in renterd
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Jan 19, 2025
1 parent 8746550 commit eac2e7a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nodes/renterd.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,17 @@ func (m *Manager) StartRenterd(ctx context.Context, sk types.PrivateKey, ready c

mux := &api.TreeMux{Sub: make(map[string]api.TreeMux)}
server := &http.Server{
Handler: mux,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "*")
w.Header().Set("Access-Control-Allow-Headers", "*")
w.Header().Set("Access-Control-Expose-Headers", "*")
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
mux.ServeHTTP(w, r)
}),
ReadTimeout: 15 * time.Second,
}
defer server.Close()
Expand Down

0 comments on commit eac2e7a

Please sign in to comment.