- Home
- Skills
- APIs & Backend
- Serve Any App Under a Path Prefix Behind a Reverse Proxy
Serve Any App Under a Path Prefix Behind a Reverse Proxy
Rewriting content at the proxy hides the bug and breaks on the first JavaScript-built URL.
$29
Works with the AI Agents you already use
Serve Any App Under a Path Prefix Behind a Reverse Proxy
Example session with this skill installed
We put our React + Express app behind nginx at https://apps.example.com/t/inventory/ and it loads a blank page; the API calls go to /api at the root and login redirects to /login. Fix it properly, no URL rewriting in nginx.
- Read your context and instructions
- Compiled the serve any app
Summary
Probed the app through the proxy, found 5 kinds of escape, fixed each at its own layer, probe now clean.
$ node scripts/prefix-probe.mjs https://apps.example.com/t/inventory/
# Path-prefix probe: https://apps.example.com/t/inventory/
3 page(s) fetched; 11 finding(s).
## attr:src (2)
- /static/js/main.3f2a.js (on https://apps.example.com/t/inventory/)
- /static/css/main.9c1e.css
## js-literal (6)
- /api/items: an inline fetch/XHR/WebSocket/EventSource target outside the prefix
- /socket ...
## redirect (1)
- /login: a 302 to a path outside the prefix (trust proxy / X-Forwarded-Prefix not applied)
## cookie-path (1)
- sid: no Path: the browser defaults it to the request directory
## service-worker-scope (1)
- /: a scope outside the prefix cannot be granted
Fixes
| Layer | Change |
|---|---|
| nginx | location /t/inventory/ { proxy_pass http://127.0.0.1:3000/; proxy_set_header X-Forwarded-Prefix /t/inventory; proxy_redirect / /t/inventory/; } plus Upgrade/Connection for the socket |
| Vite | base: '/t/inventory/' |
| React Router | <BrowserRouter basename="/t/inventory"> |
| App code | one BASE = document.baseURI constant; fetch(${BASE}api/items), new WebSocket(${wsProto}//${location.host}/t/inventory/socket) |
| Express | app.set('trust proxy', 'loopback'); res.redirect(${req.get('x-forwarded-prefix') |
| Service worker | register('/t/inventory/sw.js', { scope: '/t/inventory/' }) |
$ node scripts/prefix-probe.mjs https://apps.example.com/t/inventory/
3 page(s) fetched; 0 finding(s).
Clean: every same-origin URL the app emitted stays under the prefix.
Still to check by hand: URLs built after load in the inventory grid (open the network panel, filter paths outside /t/inventory/); the OAuth callback registered with the identity provider must be https://apps.example.com/t/inventory/auth/callback.
Connects securely to your tools. The creator never sees your data.
About this skill
When one hostname has to carry many apps (https://host/t/<name>/), the proxy strips the prefix and every URL the app emits that starts at / is wrong: blank page, 404 on assets, a redirect to /login at the host root, cookies that never come back, a service worker that refuses its scope. Rewriting content at the proxy hides the bug and breaks on the first JavaScript-built URL. The app owns its external URL model; this skill is how.
Reference (framework-settings.md)
Proxy side for nginx, Caddy and Traefik (strip, X-Forwarded-Prefix, proxy_redirect, WebSocket upgrade); build-time base for Vite, CRA/webpack, Next.js (basePath, assetPrefix), Angular, SvelteKit, Nuxt, React Router and Vue Router; server-side settings for Express, Fastify, Django, Flask/WSGI, Rails, ASP.NET Core, Spring Boot, Go and Laravel; and the ten things a base setting does not fix, each with its remedy: cookie Path, OAuth callbacks, service-worker script and scope, WebSocket and EventSource URLs, CSP, absolute redirects, canonical and og:url, CSS url(), hard-coded /api fetches.
Probe (prefix-probe.mjs)
Fetches the app through the proxy as a browser would, redirects not followed blindly, and reports every same-origin URL in src/href/action/srcset/poster, <base>, canonical, og:url, manifest, inline fetch/XHR/WebSocket literals, service-worker script and scope, 3xx Location, Set-Cookie Path and CSP connect-src that escapes the prefix, grouped by kind with the page it was on; walks a few internal links so real routes are covered. Exit 0 clean, 1 findings, 2 could not fetch. --json output.
Requirements
4 tests against loopback servers. Node 20+, no packages. Network only to the origin you name.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
No JS execution; runtime-built URLs require manual browser checks. Only audits same-origin links. Framework settings are reference maps, not documentation substitutes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago
- Software
Node.js 20+
Permissions
Shell runs node for the probe and tests. Write files: the optional --json report. Network: GET requests to the origin you name, redirects not followed automatically, up to five pages under the prefix. No environment variables, nothing changed on any server.