umami-software / umami

Umami is a simple, fast, privacy-focused alternative to Google Analytics.
https://umami.is
MIT License
22.88k stars 4.25k forks source link

Custom .env PORT being ignored? #2880

Closed ThorANilsson closed 3 months ago

ThorANilsson commented 3 months ago

Describe the Bug

I have the following .env file in the root of the Umami directory:

DATABASE_URL=url
PORT=3001

Upon building the application, Umami successfully reads the DATABASE_URL from .env. But when starting the application using start-env, the application appears to pick a random port number instead of the provided one? For example 43319 instead of 3001.

Even going into the start script start-env.js and manually changing the port to 3001, it still picks a random one when starting.

Database

PostgreSQL

Which Umami version are you using? (if relevant)

2.12.1

franciscao633 commented 3 months ago

Thanks for catching this. Can you change the start-env.js script to the below to fix.

require('dotenv').config();
const cli = require('next/dist/cli/next-start');

cli.nextStart({
  port: process.env.PORT || 3000,
  hostname: process.env.HOSTNAME || '0.0.0.0',
});
ThorANilsson commented 3 months ago

Thanks for catching this. Can you change the start-env.js script to the below to fix.

require('dotenv').config();
const cli = require('next/dist/cli/next-start');

cli.nextStart({
  port: process.env.PORT || 3000,
  hostname: process.env.HOSTNAME || '0.0.0.0',
});

That seems to work! 👍