An open-source, faster Devin alternative
TypeScript
Fix duplicate CORS headers on proxied responses
motatoes3235c2676dcc
diff --git a/internal/api/dashboard.go b/internal/api/dashboard.goindex 5fd3947e..50d62fee 100644--- a/internal/api/dashboard.go+++ b/internal/api/dashboard.go@@ -1061,6 +1061,11 @@ func (s *Server) proxyWorkerHTTP(c echo.Context, session *db.SandboxSession, met// Forward the worker's response back to the dashboardrespBody, _ := io.ReadAll(resp.Body)for k, vals := range resp.Header {+ // Skip CORS headers — the API server's own CORS middleware adds these,+ // so forwarding them from the worker causes duplicates (*, *).+ if strings.HasPrefix(strings.ToLower(k), "access-control-") {+ continue+ }for _, v := range vals {c.Response().Header().Add(k, v)}diff --git a/internal/proxy/proxy.go b/internal/proxy/proxy.goindex 9fe749e7..444f984e 100644--- a/internal/proxy/proxy.go+++ b/internal/proxy/proxy.go@@ -302,6 +302,11 @@ func (r *responseRecorder) WriteHeader(statusCode int) {func (r *responseRecorder) writeTo(w http.ResponseWriter) {for k, vals := range r.header {+ // Skip CORS headers — the outer server's CORS middleware adds these,+ // so forwarding them from the proxied response causes duplicates (*, *).+ if strings.HasPrefix(strings.ToLower(k), "access-control-") {+ continue+ }for _, v := range vals {w.Header().Add(k, v)}