Files
sign/packages/lib/universal/get-base-url.ts

21 lines
439 B
TypeScript
Raw Normal View History

2023-06-09 18:21:18 +10:00
/* eslint-disable turbo/no-undeclared-env-vars */
2024-11-21 12:32:04 +00:00
import { APP_BASE_URL } from '../constants/app';
2024-01-25 10:48:20 +02:00
2023-06-09 18:21:18 +10:00
export const getBaseUrl = () => {
if (typeof window !== 'undefined') {
return '';
}
2024-11-21 12:32:04 +00:00
const marketingAppUrl = APP_BASE_URL();
2023-06-09 18:21:18 +10:00
if (marketingAppUrl) {
return marketingAppUrl;
}
if (process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}`;
2023-06-09 18:21:18 +10:00
}
return `http://localhost:${process.env.PORT ?? 3000}`;
};