Files
oott/nix/frontend.nix
T
rzuastiandClaude Opus 4.8 cf8979f63d Fix blank /web UI and /api route under the bundled server
The Flutter web bundle was built with the default base href of "/" but is
served under "/web/", so index.html loaded while every asset reference
resolved to the site root and 404'd, leaving a blank page. Build the bundle
with --base-href=/web/ so asset URLs match the mount point.

Also correct the root guidance text (the API explorer is at /api/docs, not
/api) and add an /api -> /api/docs redirect for convenience.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 12:25:07 -04:00

28 lines
1.3 KiB
Nix

{flutter}: let
# Single source of truth: extract the version from frontend/pubspec.yaml.
# Nix has no YAML parser, so split into lines and read the `version:` line.
# (Matching the whole file with a single regex is avoided on purpose: nested
# quantifiers over the full text trigger catastrophic backtracking in Nix's
# regex engine.)
lines = builtins.filter builtins.isString (builtins.split "\n" (builtins.readFile ./../frontend/pubspec.yaml));
versionLine = builtins.head (builtins.filter (line: builtins.match "version:.*" line != null) lines);
version = builtins.head (builtins.match "version: *([^ ]+) *" versionLine);
in
flutter.buildFlutterApplication {
pname = "oott-frontend";
inherit version;
src = ./../frontend;
# Fetches pub dependencies from the committed pubspec.lock (all hosted, no git deps).
autoPubspecLock = ./../frontend/pubspec.lock;
# Build the web bundle (the backend serves these assets).
targetFlutterPlatform = "web";
# The backend serves these assets under `/web/` (see web_server::serve), so
# the bundle must be built with a matching base href. Without this the built
# index.html keeps the default `<base href="/">` and every asset reference
# resolves to the site root, 404s, and the page renders blank.
flutterBuildFlags = ["--base-href=/web/"];
}