Serve Any App Under a Path Prefix Behind a Reverse Proxy

    1

    Rewriting content at the proxy hides the bug and breaks on the first JavaScript-built URL.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    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

    LayerChange
    nginxlocation /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
    Vitebase: '/t/inventory/'
    React Router<BrowserRouter basename="/t/inventory">
    App codeone BASE = document.baseURI constant; fetch(${BASE}api/items), new WebSocket(${wsProto}//${location.host}/t/inventory/socket)
    Expressapp.set('trust proxy', 'loopback'); res.redirect(${req.get('x-forwarded-prefix')
    Service workerregister('/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.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    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

    Requires

    Node.js 20+

    Permissions

    Network Access
    Terminal / Shell
    Write Files

    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.

    Listed19 days ago

    What's inside

    Frequently Asked Questions

    This skill provides pre-configured templates for major proxies and frameworks, plus a specialized Node.js probe script that scans your app for 'prefix leaks'—broken links, cookies, or redirects that accidentally point to the root domain instead of your subfolder path.

    The skill includes ready-to-use configurations for Nginx, Caddy, and Traefik, along with build-time setup guides for popular frameworks like Vite, Next.js, Angular, SvelteKit, and several backend languages.

    You will receive a suite of configuration templates for both proxies and backends, a standalone Node.js probing script for testing, and a step-by-step remediation guide to fix common state management and OAuth issues.

    The probe script requires Node.js 20 or higher and is designed to run in any CLI environment; the configuration templates are provided in standard formats compatible with most modern AI agents and IDEs.

    Unlike generic AI advice, this skill includes a functional verification script and specific fixes for often-overlooked issues like Service Worker scopes, CSP headers, and WebSocket upgrades that standard prompts typically miss.

    The probe identifies static URL escapes in HTML and headers, but because it doesn't execute JavaScript, you will need to manually verify URLs that are constructed dynamically at runtime using the included validation checklist.

    New in APIs & Backend