LibreChat Base URL

I have seen the discussion on OpenWebUI, and it’s lack of ability to set a base url and the problems it causes.

I am trying to get LibreChat up and running as an alternative. It looks as if it allows the setting of a base url with the PUBLIC_URL env variable, but when i try to open the app once launched i get a load of errors:

manifest.webmanifest:1 
            
            
           Failed to load resource: the server responded with a status of 404 (Not Found)Understand this error
4684/:1 Manifest fetch from https://ondemand.soton.ac.uk/manifest.webmanifest failed, code 404Understand this error
math-katex.CihyawKy.css:1 
            
            
           Failed to load resource: the server responded with a status of 404 (Not Found)Understand this error
index.Bv_EI6y6.css:1 
            
            
           Failed to load resource: the server responded with a status of 404 (Not Found)Understand this error
manifest.webmanifest:1 
            
            
           Failed to load resource: the server responded with a status of 404 (Not Found)

The base url should be prefixed with: ‘node/nodename.cluster.local/4684/’, which it clearly isnt.

I am running with apptainer. My script.sh.erb to test this looks something like

#!/bin/bash
module load apptainer
module load ollama


export SANDBOX_DIR="/tmp/librechat_sandbox"

export port=$(find_port $host 2000 65000)
export PORT=$port
export host=$(hostname).cluster.local
export base_url=https://ondemand.soton.ac.uk/node/$(hostname).cluster.local:$port
export public_url=/node/$(hostname).cluster.local:$port
echo "got host: $host"
echo "got base_url: $base_url"
echo "got public_url: $public_url"
export MONGO_URI=mongodb://localhost:27017/LibreChat
JWT_SECRET=$(openssl rand -hex 32)

cat <<EOF > connection.yml
---
websocket: true
host: $host
port: $PORT
url: $base_url
EOF

echo "PORT=$PORT" >> "$SANDBOX_DIR/opt/librechat/.env"
echo "PUBLIC_URL=$public_url" >> "$SANDBOX_DIR/opt/librechat/.env"
echo "DOMAIN_CLIENT=$base_url" >> "$SANDBOX_DIR/opt/librechat/.env"
echo "DOMAIN_SERVER=$base_url" >> "$SANDBOX_DIR/opt/librechat/.env"

export HOST=0.0.0.0
echo $url

chmod 644 connection.yml

SIF_PATH="/iridisfs/home/co1f23/ondemand/dev/librechat.sif"

apptainer exec --writable --cleanenv\
  --pwd /opt/librechat \
  --bind /home/dev/librechat/mongodb_data:/data/mongodb \
  --bind /home/dev/librechat/uploads:/app/uploads \
  --bind /home/dev/librechat/logs:/data/logs \
  --bind /home/dev/librechat/librechat_logs/api_logs:/opt/librechat/api/logs \
  --bind /home/dev/librechat/librechat_logs/logs:/opt/librechat/logs \
  $SANDBOX_DIR \
  bash -c "
    echo here
    export PUBLIC_URL=$public_url
    export BASE_URL=$base_url
    export PORT=${port:-3000} 
    export HOST=0.0.0.0
    echo 'about to build'
    echo 'Built'
    mongod --dbpath /data/mongodb --bind_ip 127.0.0.1 --port 27017 --fork --logpath /data/logs/mongod.log && cd /opt/librechat && \
    npm run backend
  "

The host and port are correct, as I can see them in my connection.yml file. In the logs for Librechat I see:

Server listening on all interfaces at port 29783. Use ``http://localhost:29783`` to access it

When I log onto the host LibreCHat looks to be running, as a curl on localhost:port pulls back a response. But not when I try to access the app in the web browser.

Has anyone else tried to get this set-up and can see what I am doing incorrectly?

You’re public URL has a : in it, I think this should be /?

Hi @jeff.ohrstrom,

Thanks for spotting that. Though that wasnt the main issue - the PUBLIC_URL wasnt being exported properly, and it needs to be set before the building of the frontend (not ideal). As a test I included the front end build, and made some progress. I can see the prefix has been inserted in the relevant files of the build (eg in librechat/client/dist/manifest.webmanifest i can see the prefix under “scope”:”/node/ruby052/cluster.local/26159”, likewise in the index.html i can see things like “<script type="module" crossorigin src="/node/ruby052.cluster.local/26159/assets/index.KE1wnhvO.js"></script>)

But when I try to load the page I get errors like:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec.

Uncaught SyntaxError: Unexpected token '<'Understand this error
manifest.webmanifest:1 Manifest: Line: 1, column: 1, Syntax error.Understand this error
manifest.webmanifest:1 Manifest: Line: 1, column: 1, Syntax error.

It looks like it brings back the index.html file, not the actual manifest.webmanifest file (likewise looking in the developer tools on the page all the .js files under application seem to contain the index.html). Not sure how it is finding the index.html file, but cant find the manifest.webmanifest file