Skip to content

Static service: forward paths to another service (same-origin API for a static SPA in a profile) #551

Closed

Description

@7schmiede

Problem

ADR-0041 profiles are meant to replace a hand-written acceptance setup (#115). For a single-page app that talks to its API same-origin (relative /api, as in production behind a reverse proxy), kind = "static" is not enough: devstack serves the bundle's files only, so every /api/... request gets the SPA's index.html or a 404.

In development the dev server covers this with its proxy config (ng serve --proxy-config, Vite server.proxy). A profile that turns that dev server into kind = "static" loses the proxy, and there is nothing in the stack file to put in its place.

Seen downstream: an end-to-end acceptance run still needs a separate Compose stack with a Caddy in front (/api/*, /file/* → API, everything else → SPA, no buffering for a Server-Sent-Events stream), only because of this. Everything else (data = "fresh", workers, command + --run, skip, the lane's own ports) is already there.

Proposal

Path forwarding for a static service, settable in a profile like the other fields:

[profiles.acceptance.services.web]
kind   = "static"
build  = "npm run build -- --configuration e2e"
output = "web/dist/web"
forward = { "/api" = "{service.api.url}", "/file" = "{service.api.url}", "/otel" = "{compose.app.otel-collector.4318}" }
  • longest prefix wins; the path is passed on unchanged (a strip option could come later, cf. pathRewrite);
  • streaming responses are not buffered (SSE, chunked downloads), WebSocket upgrade passes through;
  • Host/X-Forwarded-* set as a reverse proxy would;
  • devstack check: forward only for static; targets resolve like other placeholders, so a target the profile skips is an error (as for env).

Alternatives

  • kind = "service" with run starting an own proxy (Caddy, a small Node server) in front of the build output. Works today, but every repository writes the same proxy again, and the stack file no longer says what the service is.
  • Absolute API URL in the build plus CORS on the API: changes the artifact under test and the API's configuration, so the run no longer tests what ships.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions