Skip to content

Commit 7a1f6fd

Browse files
fix(embed): untrack web/frontend/dist/* and serve a fallback stub (#473)
The .gitignore already declares `web/frontend/` "auto-generated", and every documented build path (`make build`, `make build-server`, the release.yml + pr-build.yml CI workflows, the frontend/README.md "Production Deployment" recipe) regenerates the bundle from source. But the 39+ files under web/frontend/dist/ have been tracked since a27d360, which means every `make frontend-build` produces a flood of "deleted old-hash" + "untracked-but-gitignored new-hash" entries in `git status`. This commit brings the tracked state in line with the maintainers' stated intent. Changes: 1. `git rm --cached -r web/frontend/` removes the tracked Vite output. 2. Track `web/frontend/dist/.gitkeep` so //go:embed has at least one file to embed on a fresh module fetch. 3. Track `web/embedded_fallback/index.html`, a small stub UI shown when no real Vite bundle is present. 4. Change the embed directive in web/web.go to `all:frontend/dist` (required to pick up the dotfile placeholder) and add a second embed for the fallback. The handler falls back to the stub when index.html isn't found in the real bundle. 5. `.gitignore` gains explicit re-include lines so the new .gitkeep survives the generic `dist/` ignore rule earlier in the file. 6. Makefile's `frontend-build` recreates `.gitkeep` after copying the freshly built dist into web/frontend/, so subsequent rebuilds leave a clean `git status`. User-visible behavior: | Flow | Before | After | |-----------------------------------------|---------------------|------------------------| | `make build` from a clean tree | dirty tree after | clean tree after | | `make build` re-run | dirty tree after | clean tree after | | Bare `go build ./cmd/mcpproxy` | stale embedded UI | fallback stub at /ui/ | | `go install …@latest` (no npm) | stale embedded UI | fallback stub at /ui/ | | Docker / .deb / DMG release | uses `make build` | unchanged | | CI release.yml / pr-build.yml | always rebuilds | unchanged | The trade-off is that bare-Go-toolchain users (no npm) now get a stub UI with a "build from source for the real UI" message instead of a silently-stale bundle. The REST API, MCP endpoints, and CLI are unaffected — only the `/ui/` route changes. Verified: - `go build ./...` succeeds - `make frontend-build` produces a clean `git status` - After wiping web/frontend/dist/* except .gitkeep, bare `go build ./cmd/mcpproxy` compiles and the binary serves the fallback HTML at /ui/ - `git archive HEAD | tar -x -C tmp && cd tmp && go build ./cmd/mcpproxy` (the `go install` module-fetch simulation) produces the same fallback behaviour
1 parent 0597762 commit 7a1f6fd

31 files changed

Lines changed: 84 additions & 326 deletions

.gitignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ frontend/.output/
8181
frontend/.cache/
8282
frontend/coverage/
8383

84-
# Embedded frontend assets (auto-generated)
85-
web/frontend/
84+
# Embedded frontend assets (auto-generated by `make frontend-build`).
85+
# Everything under web/frontend/dist/ is rebuilt from frontend/ on every
86+
# `make build`, except the tracked .gitkeep — it exists only so that the
87+
# //go:embed all:frontend/dist directive in web/web.go can compile from a
88+
# fresh module fetch (e.g. `go install …@latest`) before the real UI has
89+
# been produced. The explicit re-includes are needed because the generic
90+
# `dist/` rule above would otherwise mask web/frontend/dist entirely.
91+
!web/frontend/dist/
92+
web/frontend/dist/*
93+
!web/frontend/dist/.gitkeep
8694

8795
# Test coverage
8896
coverage.out

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ frontend-build:
7474
cd frontend && npm install && npm run build
7575
@echo "📁 Copying dist files for embedding..."
7676
rm -rf web/frontend
77-
mkdir -p web/frontend
78-
cp -r frontend/dist web/frontend/
77+
mkdir -p web/frontend/dist
78+
cp -r frontend/dist/. web/frontend/dist/
79+
# Recreate the tracked .gitkeep so //go:embed all:frontend/dist still has
80+
# something to embed even before the real UI is built (e.g. on a fresh
81+
# `go install …@latest`), and so subsequent rebuilds don't show a phantom
82+
# "deleted .gitkeep" in `git status`.
83+
touch web/frontend/dist/.gitkeep
7984
@echo "✅ Frontend build completed"
8085

8186
# Start frontend development server

web/embedded_fallback/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>MCPProxy — Web UI not built</title>
7+
<style>
8+
:root { color-scheme: light dark; }
9+
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; max-width: 42rem; margin: 4rem auto; padding: 0 1rem; line-height: 1.55; }
10+
h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
11+
p { margin: 0.75rem 0; }
12+
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.95em; }
13+
pre { background: rgba(127,127,127,0.12); padding: 0.75rem 1rem; border-radius: 6px; overflow-x: auto; }
14+
a { color: inherit; }
15+
</style>
16+
</head>
17+
<body>
18+
<h1>MCPProxy Web UI is not embedded in this build</h1>
19+
<p>
20+
This binary was built without running the frontend build step, so the
21+
React/Vue UI assets are not embedded. The REST API and MCP endpoints
22+
still work normally — this fallback page only replaces the
23+
<code>/ui/</code> route.
24+
</p>
25+
<p>
26+
If you installed mcpproxy with <code>go install …@latest</code> or
27+
bare <code>go build ./cmd/mcpproxy</code>, this is expected: the Go
28+
toolchain doesn't run <code>npm</code>. To get the real UI, either
29+
install a release artifact (DMG, Homebrew, .deb, .rpm, AUR, Docker)
30+
or build from source with:
31+
</p>
32+
<pre>make build # full build (swagger + frontend + backend)
33+
make build-server # server edition</pre>
34+
<p>
35+
See <a href="https://github.com/smart-mcp-proxy/mcpproxy-go#installation">the project README</a> for details.
36+
</p>
37+
</body>
38+
</html>

web/frontend/dist/.gitkeep

Whitespace-only changes.

web/frontend/dist/assets/Activity-7YqHqUto.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/frontend/dist/assets/Activity-DhitPCWU.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/frontend/dist/assets/AdminDashboard-C1SaV16-.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/frontend/dist/assets/AdminServers-Bq_mhKvu.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)