mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-25 22:35:02 +00:00
33 lines
705 B
TypeScript
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';
|
|
};
|