27 lines
575 B
JavaScript
27 lines
575 B
JavaScript
require('dotenv').config();
|
|
|
|
const DEFAULT_BASE_URL = 'https://erp-test.vavalam.com';
|
|
|
|
function normalizeBaseURL(value) {
|
|
const raw = (value || '').trim() || DEFAULT_BASE_URL;
|
|
return raw.replace(/\/+$/, '');
|
|
}
|
|
|
|
const BASE_URL = normalizeBaseURL(
|
|
process.env.BASE_URL ||
|
|
process.env.APP_BASE_URL ||
|
|
process.env.PLAYWRIGHT_BASE_URL ||
|
|
DEFAULT_BASE_URL
|
|
);
|
|
|
|
function absoluteUrl(route = '/') {
|
|
if (/^https?:\/\//i.test(route)) return route;
|
|
return new URL(route, `${BASE_URL}/`).toString();
|
|
}
|
|
|
|
module.exports = {
|
|
BASE_URL,
|
|
DEFAULT_BASE_URL,
|
|
absoluteUrl,
|
|
};
|