[GH-ISSUE #3732] [DOCS] Base URL rewrite (subdirectory) support docs #2403

Closed
opened 2026-02-22 18:29:31 -05:00 by yindo · 4 comments
Owner

Originally created by @mezut35 on GitHub (Apr 28, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3732

I’d like to propose a small documentation improvement around hosting the app under a sub-path (e.g. /anythingllm/).

Problem
Currently the .env.example and Docker Compose docs only cover core variables like SERVER_PORT, STORAGE_DIR, JWT_SECRET, and LLM/embedding providers. There is no guidance on how to set a custom base URL in order to serve the SPA from a subdirectory instead of the root (/).

Without such instructions:

Static assets (/assets/main.js, /assets/style.css, etc.) will be looked for at the wrong path and return 404 when using /anythingllm/.

Users have to patch the code manually (e.g. updating vite.config.js or React Router’s basename) without any official docs.

Originally created by @mezut35 on GitHub (Apr 28, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3732 I’d like to propose a small documentation improvement around hosting the app under a sub-path (e.g. /anythingllm/). Problem Currently the [.env.example](https://github.com/Mintplex-Labs/anything-llm/blob/master/docker/.env.example) and Docker Compose docs only cover core variables like SERVER_PORT, STORAGE_DIR, JWT_SECRET, and LLM/embedding providers. There is no guidance on how to set a custom base URL in order to serve the SPA from a subdirectory instead of the root (/). Without such instructions: Static assets (/assets/main.js, /assets/style.css, etc.) will be looked for at the wrong path and return 404 when using /anythingllm/. Users have to patch the code manually (e.g. updating vite.config.js or React Router’s basename) without any official docs.
yindo added the good first issuedocumentation labels 2026-02-22 18:29:31 -05:00
yindo closed this issue 2026-02-22 18:29:31 -05:00
Author
Owner

@jberdah commented on GitHub (Apr 28, 2025):

I'm currently working on a fork adapting the code to do exactly this ...
It's not only the assets that won't be served at the right place, there are many other things to adjust in the code
My objective is to have a custom docker image built,

@jberdah commented on GitHub (Apr 28, 2025): I'm currently working on a fork adapting the code to do exactly this ... It's not only the assets that won't be served at the right place, there are many other things to adjust in the code My objective is to have a custom docker image built,
Author
Owner

@timothycarambat commented on GitHub (Apr 28, 2025):

We have always instructed users to just use a reverse proxy with something like NGINX, since you are probably going to wind up deploying the container behind a web server & you're probably going to want SSL as well.

Its not really worth doing a bunch of work to get that functionality via custom code (but you may have your own specific requirements!)

Example

server {
    listen 80;
    server_name yourdomain.com;

    # WebSocket support for agent-invocation API
    location ~* ^/api/agent-invocation/(.*) {
        proxy_pass http://0.0.0.0:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Serve AnythingLLM frontend under /anythingllm/ sub-dir
    location /anythingllm/ {
        proxy_pass http://0.0.0.0:3001/; 
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        rewrite ^/anythingllm/(.*)$ /$1 break;
    }
}

This is more of a configuration/setup issue that is not something explicitly related to the codebase itself, however everyone has preferences on how to run things so you can always do your own fork if required

@timothycarambat commented on GitHub (Apr 28, 2025): We have always instructed users to just use a reverse proxy with something like NGINX, since you are probably going to wind up deploying the container behind a web server & you're probably going to want SSL as well. Its not really worth doing a bunch of work to get that functionality via custom code (but you may have your own specific requirements!) Example ```nginx server { listen 80; server_name yourdomain.com; # WebSocket support for agent-invocation API location ~* ^/api/agent-invocation/(.*) { proxy_pass http://0.0.0.0:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Serve AnythingLLM frontend under /anythingllm/ sub-dir location /anythingllm/ { proxy_pass http://0.0.0.0:3001/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; rewrite ^/anythingllm/(.*)$ /$1 break; } } ``` This is more of a configuration/setup issue that is not something explicitly related to the codebase itself, however everyone has preferences on how to run things so you can always do your own fork if required
Author
Owner

@jberdah commented on GitHub (Apr 28, 2025):

Thanks a lot for your input, indeed that's what I thought at first. That I would just need to configure traefik and environment variables,, but so far I had to patch a few things in the code to overpass some cases (node not going through proxy, hardcoded links and window.location, etc ...).
Anways, I'll give your input a try, hopefully it will save me a lot of time :)

@jberdah commented on GitHub (Apr 28, 2025): Thanks a lot for your input, indeed that's what I thought at first. That I would just need to configure traefik and environment variables,, but so far I had to patch a few things in the code to overpass some cases (node not going through proxy, hardcoded <a> links and window.location, etc ...). Anways, I'll give your input a try, hopefully it will save me a lot of time :)
Author
Owner

@nader939 commented on GitHub (Jun 24, 2025):

I still think that static assets like index.js need to move to suburl/index.js, even with proxy settings given above, and this needs some change at frontend code

@nader939 commented on GitHub (Jun 24, 2025): I still think that static assets like index.js need to move to suburl/index.js, even with proxy settings given above, and this needs some change at frontend code
yindo changed title from [DOCS] Base URL rewrite (subdirectory) support docs to [GH-ISSUE #3732] [DOCS] Base URL rewrite (subdirectory) support docs 2026-06-05 14:46:21 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2403