Skip to content

[Bug]: den-web runtime-config serves the internal DEN_API_BASE to the browser (split-origin self-host), breaking all client API calls — regression in 0.18.37 #4153

Closed

Description

@berenddeboer

Summary

On a split-origin self-hosted Den (separate web and API hostnames), den-web's /api/runtime-config hands the browser the internal Den API URL instead of the public API origin, so every client-side call fails with NetworkError when attempting to fetch resource and the dashboard cannot even complete sign-in.

GET /api/runtime-config returns:

{
  "denApiUrl": "http://openwork-openwork-ee-den-api:8788",
  ...
}

http://openwork-openwork-ee-den-api:8788 is the in-cluster Kubernetes Service address — plain HTTP, cluster-internal DNS. No browser (or Desktop app) can reach it. It should be the public API origin, e.g. https://den-api.example.com.

This worked on 0.18.35 and broke on 0.18.37.

Root cause

ee/apps/den-web/app/api/runtime-config/route.ts computes the browser-facing API URL as:

denApiUrl: readBaseUrlEnv(process.env, "DEN_API_BASE") ?? denUrls(process.env).api

DEN_API_BASE is the internal base used for server-side/SSR calls (the Helm chart defaults it to http://<release>-den-api:8788, and it is referenced ~27× server-side). Because it is always set, denApiUrl is always the internal URL and the denUrls(process.env).api fallback (which resolves the correct public origin) is never reached.

Meanwhile the chart exposes the public origin as DEN_API_PUBLIC_URL (from config.public.apiOrigin), and den-web never reads it:

  • grep -rl DEN_API_PUBLIC_URL ee/apps/den-web -> no matches
  • grep -rl DEN_API_PUBLIC_URL ee/apps/den-api -> dist/env.js, dist/request-url.js, etc.

So den-api consumes DEN_API_PUBLIC_URL, but den-web's runtime-config ignores it and leaks the internal SSR base to the browser. That asymmetry is the bug.

To Reproduce

  1. Deploy the Den self-hosted with split origins: web on https://den.example.com, API on https://den-api.example.com (chart config.public.webOrigin + config.public.apiOrigin), den-api Service as ClusterIP reached via ingress. DEN_API_BASE keeps its chart default (http://<release>-den-api:8788).
  2. Open https://den.example.com/ in a browser and enter the owner email, click Next.
  3. Observe the request to the API fail; the page shows NetworkError when attempting to fetch resource and login cannot proceed.
  4. curl https://den.example.com/api/runtime-config shows "denApiUrl":"http://<release>-den-api:8788".

Expected behavior

runtime-config.denApiUrl is the public API origin (https://den-api.example.com) — reachable by the browser — while server-side code continues to use the internal DEN_API_BASE. i.e. the browser value should derive from DEN_API_PUBLIC_URL / denUrls().api, not from the internal SSR base.

Actual behavior

runtime-config.denApiUrl is the internal ClusterIP Service URL (http://<release>-den-api:8788); all browser API calls throw NetworkError; sign-in is impossible from the web UI. Same value is served to the Desktop app.

Suggested fix

In runtime-config/route.ts, prefer the public origin for the browser value:

denApiUrl: readBaseUrlEnv(process.env, "DEN_API_PUBLIC_URL")
        ?? denUrls(process.env).api
        // do NOT fall through to the internal DEN_API_BASE for a browser-facing value

i.e. DEN_API_BASE should stay server-side only and never be the source for runtime-config.denApiUrl. Single-origin deployments are unaffected because webOrigin-derived defaults still resolve.

OW version & info

  • OpenWork version: 0.18.37 (regression; 0.18.35 worked)
  • Self-hosted Den (Enterprise), split web/API origins, den-api Service ClusterIP behind ingress
  • Chart: openwork-ee-0.18.37

Additional context

The chart sets both DEN_API_PUBLIC_URL (public, from config.public.apiOrigin) and DEN_API_BASE (internal default). Since den-web ignores the former, the only config-level workaround is to point config.internal.apiBaseUrl (→ DEN_API_BASE) at the public origin — which forces in-cluster den-web↔den-api traffic to hairpin out through the public ingress. A code fix that keeps DEN_API_BASE server-side-only avoids that tradeoff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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