# Configure base URL / path prefix for LangGraph Agent Server behind reverse proxy

**URL:** https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252
**Category:** LangSmith Product Help
**Tags:** self-hosted
**Created:** [March 26, 2026, 5:13pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252 "2026-03-26T17:13:21Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![gdrouet](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/gdrouet/32/2429_2.png) [@gdrouet](https://forum.langchain.com/u/gdrouet)
#### Post date: [March 26, 2026, 5:13pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/1 "2026-03-26T17:13:21Z")

</div>

Hi,

I’m running the LangGraph Agent Server using the official Docker image behind a reverse proxy with a path prefix.

### Context

My public endpoint is:

```auto
<<host>>/api/agent-server

```

The proxy forwards requests to the agent server container.

### Issue

The A2A card returned by the server contains URLs like:

```auto
<<host>>/a2a/{id}

```

However, the actual working URL is:

```auto
<<host>>/api/agent-server/a2a/{id}

```

So the `/api/agent-server` prefix is missing in generated URLs.

### Question

Is there a supported way to configure a **base URL** or **path prefix** for the Agent Server so that generated URLs (like A2A card URLs) include `/api/agent-server`?

Thanks!

---

<div class="post-metadata">

### Author: ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)
#### Post date: [March 26, 2026, 8:35pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/2 "2026-03-26T20:35:53Z")

</div>

Yes the Agent Server supports this via the **`MOUNT_PREFIX`** environment variable ( though available in self-hosted deployments only).

Set `MOUNT_PREFIX` to your path prefix and the server will mount all of its routes under that prefix. This means both **incoming request routing** and **generated URLs** (like A2A card links) will include the prefix.

```bash
docker run \
  -e MOUNT_PREFIX="/api/agent-server" \
  -e REDIS_URI="redis://..." \
  -e DATABASE_URI="postgres://..." \
  -e LANGSMITH_API_KEY="..." \
  -p 8124:8000 \
  my-agent-image

```

With `MOUNT_PREFIX="/api/agent-server"`, the server’s routes become:

- `/api/agent-server/ok`
- `/api/agent-server/a2a/{id}`
- `/api/agent-server/.well-known/agent-card.json`
- etc.

And generated A2A card URLs will correctly include the prefix:

```auto
https://<host>/api/agent-server/a2a/{id}

```

### Reverse proxy configuration

Since `MOUNT_PREFIX` makes the server expect the full prefixed path, your reverse proxy should **pass the path through as-is** (do not strip the prefix):

```nginx
location /api/agent-server/ {
    proxy_pass http://agent-server:8000; # NO trailing slash — preserves the full path
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
}

```

### Relevant docs

- [`MOUNT_PREFIX` documentation](https://docs.langchain.com/langsmith/env-var#mount_prefix)
- [A2A endpoint in Agent Server](https://docs.langchain.com/langgraph-platform/server-a2a)
- [Self-host standalone servers](https://docs.langchain.com/langgraph-platform/deploy-standalone-server)

* * *

---

<div class="post-metadata">

### Author: ![gdrouet](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/gdrouet/32/2429_2.png) [@gdrouet](https://forum.langchain.com/u/gdrouet)
#### Post date: [April 1, 2026, 2:41pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/3 "2026-04-01T14:41:28Z")

</div>

Hello,

It almost work, but the URL generated in the agent-card.json does not include the prefix path.

I’m using Traeffik as reverse proxy.

Can you explain in this particular case what the Agent Server uses to include a prefix path?

---

<div class="post-metadata">

### Author: ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)
#### Post date: [April 1, 2026, 4:49pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/4 "2026-04-01T16:49:46Z")

</div>

Good observation - this appears to be a gap in how the Agent Server constructs URLs for `agent-card.json`.

Here’s what we know from the [Agent Server changelog](https://docs.langchain.com/langsmith/langgraph-server-changelog) and [environment variable docs](https://docs.langchain.com/langsmith/env-var#mount_prefix):

**What `MOUNT_PREFIX` does:**  
It mounts all server routes under the specified path prefix (e.g., `/api/agent-server/ok`, `/api/agent-server/a2a/{id}`, etc.). This handles **request routing** correctly.

**What the server uses for agent card URLs:**  
Per changelog entry **v0.7.38** , the server reads `X-Forwarded-Proto` to determine the correct scheme (`https` vs `http`) in agent card URLs. However, there’s no documented mechanism for the **path prefix** being included in the generated `url` field of the agent card.

**What you can try:**

1. Ensure your Traefik proxy forwards these headers:

2. Make sure you’re on `langgraph-api >= 0.7.38` to get the `X-Forwarded-Proto` support for agent cards.

3. If the prefix is still missing from the generated agent card URL despite `MOUNT_PREFIX` being set, this may be a bug or missing feature – the server constructs the card URL from the incoming request but may not be incorporating `MOUNT_PREFIX` into the generated `url` field.

If the above doesn’t resolve it, I’d recommend filing a GitHub issue on [langchain-ai/langgraph](https://github.com/langchain-ai/langgraph) requesting that `MOUNT_PREFIX` be reflected in A2A agent card URL generation, or that a dedicated env var (e.g., `PUBLIC_BASE_URL`) be added for explicitly controlling the base URL in generated agent cards. This is a [known pattern in the A2A ecosystem](https://github.com/a2aproject/A2A/issues/1599) where agent cards advertise internal URLs instead of externally reachable ones when running behind proxies.

---

<div class="post-metadata">

### Author: ![gdrouet](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/gdrouet/32/2429_2.png) [@gdrouet](https://forum.langchain.com/u/gdrouet)
#### Post date: [April 2, 2026, 7:42am UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/5 "2026-04-02T07:42:01Z")

</div>

Thanks. I have interesting observations here.

First `X-Forwarded-Proto` is correctly used. If I configure it in my proxy the value is reflected to the generated URL.

Second, and maybe most important, generated URL includes the prefix when I test my application without a proxy (local container or using a k8s post-forward). Therefore the Agent Server includes a mechanism that uses the `MOUNT_PREFIX` to generate the agent card URLs. However, something in the proxy affects this mechanism.

---

<div class="post-metadata">

### Author: ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)
#### Post date: [April 2, 2026, 10:38am UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/6 "2026-04-02T10:38:10Z")

</div>

That’s a very useful observation and it clarifies the issue **further**.

Since the agent card URLs **do** include the prefix when you access the server directly (without a proxy), the Agent Server **is** using `MOUNT_PREFIX` to construct URLs correctly. The problem is that something in the proxy setup overrides or bypasses this mechanism.

The most likely cause: **your Traefik configuration is stripping the path prefix before forwarding the request to the server.**

If you’re using Traefik’s `stripPrefix` middleware (JUST THINKING ABOUT A POSSIBILITY):

```yaml
middlewares:
  strip-agent-server:
    stripPrefix:
      prefixes:
        - "/api/agent-server"

```

Then here’s what happens:

```auto
Client request: GET /api/agent-server/.well-known/agent-card.json
                          ↓
Traefik strips: GET /.well-known/agent-card.json ← prefix removed
                          ↓
Server receives: /.well-known/agent-card.json
                  Server sees no prefix in the request path,
                  so it generates URLs WITHOUT the prefix

```

When you hit the server directly (no proxy), the request arrives at `/api/agent-server/.well-known/agent-card.json` — the server sees the full path including the prefix it mounted via `MOUNT_PREFIX`, so it generates correct URLs.

**The fix:** Since `MOUNT_PREFIX` makes the server expect and serve routes under `/api/agent-server/...`, you should **not strip the prefix** in Traefik. Pass the full path through:

```yaml
http:
  routers:
    agent-server:
      rule: "PathPrefix(`/api/agent-server`)"
      service: agent-server
      # No stripPrefix middleware

  services:
    agent-server:
      loadBalancer:
        servers:
          - url: "http://agent-server:8000"

```

This way the request arrives at the server with the full path intact, `MOUNT_PREFIX` matches it, and the generated agent card URLs will include the prefix – just like when you access the server directly.

**TL;DR:** `MOUNT_PREFIX` handles both routing and URL generation, but only when it sees the prefix in the incoming request path. If the proxy strips it, the server falls back to prefix-less URL generation. Remove `stripPrefix` from your Traefik config and let `MOUNT_PREFIX` handle everything.

---

<div class="post-metadata">

### Author: ![gdrouet](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/gdrouet/32/2429_2.png) [@gdrouet](https://forum.langchain.com/u/gdrouet)
#### Post date: [April 2, 2026, 1:17pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/7 "2026-04-02T13:17:29Z")

</div>

I already checked this and the path is not stripped.

Actually, since `MOUNT_PREFIX` is set, stripping the path would cause the server to respond a 404 because it serves all the routes under `/api/agent-server`.

I played with my local container and tried to send requests with some modified headers. I finally reproduced the issue by adding a `Host` header to my request. When `Host` header is present, the prefix path is missing from the generated URL (while the `Host` value is correctly used to adjust the domain).

I filled an issue: [MOUNT\_PREFIX ignored in generated URLs for agent cards when Host header is set (reverse proxy scenario) · Issue #7390 · langchain-ai/langgraph · GitHub](https://github.com/langchain-ai/langgraph/issues/7390)

---

<div class="post-metadata">

### Author: ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)
#### Post date: [April 3, 2026, 12:52pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/8 "2026-04-03T12:52:04Z")

</div>

Okay, thanks for opening the issue on the langgraph repo. Let’s keep this thread open as well for now.  
I feel like one of the official team members will be better able to help you out now.  
CC: @eyurtsev @mdrxy

---

<div class="post-metadata">

### Author: ![wfh](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/wfh/32/33_2.png) [@wfh](https://forum.langchain.com/u/wfh)
#### Post date: [April 3, 2026, 1:32pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/9 "2026-04-03T13:32:53Z")

</div>

Thanks for reporting. A workaround today is to set LANGGRAPH\_API\_URL, but we’ll push a fix.

---

<div class="post-metadata">

### Author: ![gdrouet](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/gdrouet/32/2429_2.png) [@gdrouet](https://forum.langchain.com/u/gdrouet)
#### Post date: [April 3, 2026, 3:05pm UTC](https://forum.langchain.com/t/configure-base-url-path-prefix-for-langgraph-agent-server-behind-reverse-proxy/3252/10 "2026-04-03T15:05:46Z")

</div>

Thanks. It resolves the issue. Is it possible to document the `LANGGRAPH_API_URL`at [Environment variables - Docs by LangChain](https://docs.langchain.com/langsmith/env-var) ?
