mirror of
https://github.com/documenso/documenso.git
synced 2025-11-26 14:34:05 +10:00
Support runtime environment variables using server components. This will mean docker images can change env vars for runtime as required.
21 lines
470 B
TypeScript
21 lines
470 B
TypeScript
import { useRuntimeEnv } from './runtime-env/client';
|
|
|
|
/* eslint-disable turbo/no-undeclared-env-vars */
|
|
export const useBaseUrl = () => {
|
|
const { NEXT_PUBLIC_WEBAPP_URL } = useRuntimeEnv();
|
|
|
|
if (typeof window !== 'undefined') {
|
|
return '';
|
|
}
|
|
|
|
if (process.env.VERCEL_URL) {
|
|
return `https://${process.env.VERCEL_URL}`;
|
|
}
|
|
|
|
if (NEXT_PUBLIC_WEBAPP_URL) {
|
|
return NEXT_PUBLIC_WEBAPP_URL;
|
|
}
|
|
|
|
return `http://localhost:${process.env.PORT ?? 3000}`;
|
|
};
|