Skip to content

Commit

Permalink
fix renterd cors
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 19, 2024
1 parent 28f4118 commit 41ffeba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion nodes/hostd.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func (m *Manager) StartHostd(ctx context.Context, ready chan<- struct{}) error {
api.ServerWithWebhooks(wr),
api.ServerWithPinnedSettings(pm),
api.ServerWithExplorer(ex)))

server := http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
Expand Down
10 changes: 5 additions & 5 deletions nodes/renterd.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error

var workerHandler, busHandler, autopilotHandler http.Handler
server := &http.Server{
Handler: jape.BasicAuth("sia is cool")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
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", "*")
Expand All @@ -186,7 +186,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
return
}
http.NotFound(w, r)
})),
}),
ReadTimeout: 15 * time.Second,
}
defer server.Close()
Expand All @@ -210,7 +210,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
log.Error("failed to shutdown bus", zap.Error(err))
}
}()
busHandler = b.Handler()
busHandler = jape.BasicAuth("sia is cool")(b.Handler())

apiAddr := apiListener.Addr().String()
busClient := bus.NewClient(fmt.Sprintf("http://%s/api/bus", apiAddr), "sia is cool")
Expand Down Expand Up @@ -239,7 +239,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
log.Error("failed to shutdown worker", zap.Error(err))
}
}()
workerHandler = w.Handler()
workerHandler = jape.BasicAuth("sia is cool")(w.Handler())

ap, err := autopilot.New(config.Autopilot{
AccountsRefillInterval: time.Second,
Expand All @@ -256,7 +256,7 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
return fmt.Errorf("failed to create autopilot: %w", err)
}
defer ap.Shutdown(ctx)
autopilotHandler = ap.Handler()
autopilotHandler = jape.BasicAuth("sia is cool")(ap.Handler())

log.Info("node started", zap.Stringer("http", apiListener.Addr()))
node.APIAddress = "http://" + apiListener.Addr().String()
Expand Down

0 comments on commit 41ffeba

Please sign in to comment.