env
All checks were successful
Build & Deploy KLZ Cables / build-and-deploy (push) Successful in 3m46s
All checks were successful
Build & Deploy KLZ Cables / build-and-deploy (push) Successful in 3m46s
This commit is contained in:
@@ -12,20 +12,40 @@ const getEnv = (key: string, defaultValue?: string): string | undefined => {
|
||||
return (process.env as any)[key] || defaultValue;
|
||||
}
|
||||
|
||||
if (typeof process === 'undefined') return defaultValue;
|
||||
if (typeof process === 'undefined') return defaultValue;
|
||||
|
||||
// In Docker/Production, variables are in process.env
|
||||
// In local development, they might be in .env
|
||||
const value = process.env[key];
|
||||
|
||||
if (value !== undefined && value !== '') {
|
||||
return value;
|
||||
// Check for quoted values (common when passed via SSH/Docker)
|
||||
if (typeof value === 'string') {
|
||||
const trimmed = value.trim();
|
||||
if ((trimmed.startsWith("'") && trimmed.endsWith("'")) ||
|
||||
(trimmed.startsWith('"') && trimmed.endsWith('"'))) {
|
||||
return trimmed.slice(1, -1);
|
||||
}
|
||||
if (trimmed !== '') return trimmed;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
const isProduction = getEnv('NODE_ENV') === 'production';
|
||||
|
||||
// Required variables in production
|
||||
if (isProduction && typeof window === 'undefined') {
|
||||
const required = [
|
||||
'NEXT_PUBLIC_BASE_URL',
|
||||
];
|
||||
|
||||
for (const key of required) {
|
||||
if (!getEnv(key)) {
|
||||
throw new Error(`Missing required environment variable: ${key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const config = {
|
||||
env: getEnv('NODE_ENV', 'development'),
|
||||
isProduction: getEnv('NODE_ENV') === 'production',
|
||||
@@ -37,7 +57,7 @@ export const config = {
|
||||
analytics: {
|
||||
umami: {
|
||||
websiteId: getEnv('NEXT_PUBLIC_UMAMI_WEBSITE_ID'),
|
||||
scriptUrl: getEnv('UMAMI_SCRIPT_URL', 'https://analytics.infra.mintel.me/script.js'),
|
||||
scriptUrl: getEnv('NEXT_PUBLIC_UMAMI_SCRIPT_URL', 'https://analytics.infra.mintel.me/script.js'),
|
||||
// The proxied path used in the frontend
|
||||
proxyPath: '/stats/script.js',
|
||||
enabled: Boolean(getEnv('NEXT_PUBLIC_UMAMI_WEBSITE_ID')),
|
||||
@@ -74,16 +94,6 @@ export const config = {
|
||||
from: getEnv('MAIL_FROM'),
|
||||
recipients: getEnv('MAIL_RECIPIENTS', '')?.split(',').filter(Boolean) || [],
|
||||
},
|
||||
|
||||
woocommerce: {
|
||||
url: getEnv('WOOCOMMERCE_URL'),
|
||||
consumerKey: getEnv('WOOCOMMERCE_CONSUMER_KEY'),
|
||||
consumerSecret: getEnv('WOOCOMMERCE_CONSUMER_SECRET'),
|
||||
},
|
||||
|
||||
wordpress: {
|
||||
appPassword: getEnv('WORDPRESS_APP_PASSWORD'),
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user