npm i base-path-env
const { getBasePath } = require("base-path-env");
const basePath = getBasePath();
In order for this to work, you need to specify in your .env
file the BASE_PATH variable, or you can just export the env variable. Eg.:
BASE_PATH=subdomain/