From 86b4cf035a6741df03b150006d6034a988b1fc45 Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 13 Nov 2024 10:43:19 -0700 Subject: [PATCH] fix: CORS errors with additional headers in local dev (#3379) Fixes #3378 --- backend/controller/timeline/events_ingress.go | 2 +- frontend/cli/cmd_serve.go | 5 +++++ frontend/console/src/features/verbs/VerbRequestForm.tsx | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/controller/timeline/events_ingress.go b/backend/controller/timeline/events_ingress.go index c218f7624..325b4684f 100644 --- a/backend/controller/timeline/events_ingress.go +++ b/backend/controller/timeline/events_ingress.go @@ -126,7 +126,7 @@ func (s *Service) insertHTTPIngress(ctx context.Context, querier sql.Querier, in return fmt.Errorf("failed to encrypt ingress payload: %w", err) } - log.FromContext(ctx).Warnf("Inserting ingress event for %s %s", ingress.RequestKey, ingress.Path) + log.FromContext(ctx).Debugf("Inserting ingress event for %s %s", ingress.RequestKey, ingress.Path) err = libdal.TranslatePGError(querier.InsertTimelineIngressEvent(ctx, sql.InsertTimelineIngressEventParams{ DeploymentKey: ingress.DeploymentKey, diff --git a/frontend/cli/cmd_serve.go b/frontend/cli/cmd_serve.go index 533d5d3b5..80be0d25f 100644 --- a/frontend/cli/cmd_serve.go +++ b/frontend/cli/cmd_serve.go @@ -149,6 +149,11 @@ func (s *serveCmd) run( s.CommonConfig.AllowOrigins = append(s.CommonConfig.AllowOrigins, addr) } + if devMode && len(s.CommonConfig.AllowHeaders) == 0 { + // Default to allowing all headers for console requests in local dev mode. + s.CommonConfig.AllowHeaders = []string{"*"} + } + provisionerAddresses := make([]*url.URL, 0, s.Provisioners) for range s.Provisioners { bind, err := bindAllocator.Next() diff --git a/frontend/console/src/features/verbs/VerbRequestForm.tsx b/frontend/console/src/features/verbs/VerbRequestForm.tsx index 8d828c93a..90c77b3ac 100644 --- a/frontend/console/src/features/verbs/VerbRequestForm.tsx +++ b/frontend/console/src/features/verbs/VerbRequestForm.tsx @@ -166,7 +166,7 @@ export const VerbRequestForm = ({ module, verb }: { module?: Module; verb?: Verb } }, [verb, bodyTextKey]) - const bottomText = response ?? error ?? '' + const bottomText = response || error || '' const schemaString = verb ? JSON.stringify(simpleJsonSchema(verb)) : '' return (