BASE_URL not being overridden when set as environment variable

When running the self hosted version of plausible BASE_URL is not used correctly.
Adding a site results in the following javascript snippet:
<script async defer data-domain="example.com" src="http://localhost:8000/js/plausible.js"></script>

It is possible to fix this by changing the src to this, however the problem then occurs when plausible attemps to store events:

Request URL: http://localhost:8000/api/event
Referrer Policy: strict-origin-when-cross-origin
Provisional headers are shown
Content-Type: text/plain
Referer: http://example.com:8080/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
{n: "pageview", u: "http://example.com:8080/customer/1", d: null,…}
d: null
n: "pageview"
r: "http://example.com:8080/customer"
u: "http://example.com:8080/customer/1"
w: 2133

Using the following environment variables:

ADMIN_USER_EMAIL=foo@bar.com
ADMIN_USER_NAME=foo
ADMIN_USER_PWD=password
BASE_URL=example.com
SECRET_KEY_BASE=ixqekwmzhsxfywuldfshryykbpnvxacqemafshzmpctauduwvbfdwahfxdisyvwa
HOST=example.com

environment in the container:

root@dd98fdeb7d23:/app# env
BASE_URL=example.com
HOSTNAME=dd98fdeb7d23
ADMIN_USER_EMAIL=foo@bar.com
PWD=/app
HOME=/root
LANG=C.UTF-8
ADMIN_USER_PWD=password
TERM=xterm
HOST=example.com
SHLVL=1
SECRET_KEY_BASE=ixqekwmzhsxfywuldfshryykbpnvxacqemafshzmpctauduwvbfdwahfxdisyvwa
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ADMIN_USER_NAME=foo
_=/usr/bin/env

Issue resolved.
BASE_URL will fallback on default if http:// is not added infront of the value set.

1 Like

good to hear! thank you for reporting back!