From 2612de8446e3c0669dd418b9bbb20e122f8b7101 Mon Sep 17 00:00:00 2001 From: jordan Date: Mon, 23 Feb 2026 11:52:03 -0700 Subject: [PATCH] fix: inject SERVICE_NAME/SERVICE_PORT for app components in batch path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AddComponentBatch was missing the SERVICE_NAME injection that AddComponent has. When an app-react component (e.g. creator-ui) was rendered via the batch endpoint alongside a service component, {{SERVICE_NAME}} in App.tsx.tmpl was never substituted — rendering the literal string into the repo. Fix: scan the batch's own code requests for a service component first (since the service isn't in the DB yet during batch processing), then fall back to findFirstServiceComponent from DB. This is the same AddComponent vs AddComponentBatch parity gap that caused the JWT_SECRET issue (RC-2). The auth API URL in every app-react project was broken when deployed via the batch endpoint. Co-Authored-By: Claude Sonnet 4.6 --- internal/service/component_batch.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/service/component_batch.go b/internal/service/component_batch.go index beb61c5..ea9b58f 100644 --- a/internal/service/component_batch.go +++ b/internal/service/component_batch.go @@ -153,6 +153,30 @@ func (s *ComponentService) AddComponentBatch(ctx context.Context, projectID stri "DOMAIN": projectDomain, } + // For frontend apps, inject the primary service name/port for API proxy. + // Check the batch itself first (service not yet in DB), then fall back to DB. + if componentType.IsAppComponent() { + var svcName string + var svcPort int + for _, r := range codeReqs { + if domain.ComponentType(r.Type) == domain.ComponentTypeService { + svcName = r.Name + svcPort = r.Port + break + } + } + if svcName == "" { + if svc := s.findFirstServiceComponent(ctx, projectID); svc != nil { + svcName = svc.Name + svcPort = svc.Port + } + } + if svcName != "" { + vars["SERVICE_NAME"] = svcName + vars["SERVICE_PORT"] = strconv.Itoa(svcPort) + } + } + // Get component template files componentFiles, err := s.templateProvider.GetComponentFiles(ctx, req.Type, componentPath, vars) if err != nil {