Files
postgres/src/utils/Helpers.ts
2026-01-08 01:04:26 +00:00

33 lines
705 B
TypeScript

import { routing } from '@/libs/I18nRouting';
export const getBaseUrl = () => {
if (process.env.NEXT_PUBLIC_APP_URL) {
return process.env.NEXT_PUBLIC_APP_URL;
}
if (
process.env.VERCEL_ENV === 'production'
&& process.env.VERCEL_PROJECT_PRODUCTION_URL
) {
return `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`;
}
if (process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}`;
}
return 'http://localhost:3000';
};
export const getI18nPath = (url: string, locale: string) => {
if (locale === routing.defaultLocale) {
return url;
}
return `/${locale}${url}`;
};
export const isServer = () => {
return typeof window === 'undefined';
};