mirror of
https://github.com/documenso/documenso.git
synced 2025-11-26 14:34:05 +10:00
feat: runtime env
Support runtime environment variables using server components. This will mean docker images can change env vars for runtime as required.
This commit is contained in:
20
packages/lib/universal/use-base-url.ts
Normal file
20
packages/lib/universal/use-base-url.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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}`;
|
||||
};
|
||||
Reference in New Issue
Block a user