remove 'NEXT_PUBLIC_' prefix from variables
This commit is contained in:
parent
78f181b17e
commit
9f857e55a9
8
.env
8
.env
@ -1,10 +1,10 @@
|
||||
####### COMMON #######
|
||||
NEXT_PUBLIC_USE_DEV_COLORS=
|
||||
USE_DEV_COLORS=
|
||||
|
||||
####### USERS ########
|
||||
USERS_SUPER=["akalinina","vchikalkin"]
|
||||
|
||||
####### URLS ########
|
||||
NEXT_PUBLIC_URL_GET_USER_DIRECT=
|
||||
NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT=
|
||||
NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT=
|
||||
URL_GET_USER_DIRECT=
|
||||
URL_CRM_GRAPHQL_DIRECT=
|
||||
URL_CORE_FINGAP_DIRECT=
|
||||
@ -3,7 +3,7 @@ module.exports = {
|
||||
client: {
|
||||
service: {
|
||||
name: 'crmgraphql',
|
||||
url: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
url: process.env.URL_CRM_GRAPHQL_DIRECT,
|
||||
localSchemaFile: './graphql/crm.schema.graphql',
|
||||
},
|
||||
excludes: ['graphql/**/*'],
|
||||
|
||||
@ -2,15 +2,15 @@
|
||||
const { z } = require('zod');
|
||||
|
||||
const envSchema = z.object({
|
||||
NEXT_PUBLIC_USE_DEV_COLORS: z
|
||||
USE_DEV_COLORS: z
|
||||
.unknown()
|
||||
.optional()
|
||||
.transform((val) => !!val),
|
||||
PORT: z.string().optional(),
|
||||
NEXT_PUBLIC_BASE_PATH: z.string().optional().default(''),
|
||||
NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
NEXT_PUBLIC_URL_GET_USER_DIRECT: z.string(),
|
||||
NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT: z.string(),
|
||||
BASE_PATH: z.string().optional().default(''),
|
||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
URL_GET_USER_DIRECT: z.string(),
|
||||
URL_CORE_FINGAP_DIRECT: z.string(),
|
||||
});
|
||||
|
||||
module.exports = envSchema;
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
const envSchema = require('./env');
|
||||
|
||||
const publicRuntimeConfigSchema = envSchema.pick({
|
||||
NEXT_PUBLIC_BASE_PATH: true,
|
||||
NEXT_PUBLIC_USE_DEV_COLORS: true,
|
||||
BASE_PATH: true,
|
||||
USE_DEV_COLORS: true,
|
||||
});
|
||||
|
||||
const serverRuntimeConfigSchema = envSchema.pick({
|
||||
PORT: true,
|
||||
NEXT_PUBLIC_BASE_PATH: true,
|
||||
NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT: true,
|
||||
NEXT_PUBLIC_URL_GET_USER_DIRECT: true,
|
||||
NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT: true,
|
||||
BASE_PATH: true,
|
||||
URL_CRM_GRAPHQL_DIRECT: true,
|
||||
URL_GET_USER_DIRECT: true,
|
||||
URL_CORE_FINGAP_DIRECT: true,
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -7,31 +7,26 @@ const { serverRuntimeConfig, publicRuntimeConfig } = getConfig();
|
||||
|
||||
function getUrls() {
|
||||
if (isServer()) {
|
||||
const {
|
||||
NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
NEXT_PUBLIC_URL_GET_USER_DIRECT,
|
||||
NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT,
|
||||
NEXT_PUBLIC_BASE_PATH,
|
||||
PORT,
|
||||
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||
const { URL_CRM_GRAPHQL_DIRECT, URL_GET_USER_DIRECT, URL_CORE_FINGAP_DIRECT, BASE_PATH, PORT } =
|
||||
serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||
|
||||
return {
|
||||
PORT,
|
||||
BASE_PATH: NEXT_PUBLIC_BASE_PATH,
|
||||
URL_CRM_GRAPHQL: NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
URL_GET_USER: NEXT_PUBLIC_URL_GET_USER_DIRECT,
|
||||
URL_CORE_FINGAP: NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT,
|
||||
BASE_PATH,
|
||||
URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_DIRECT,
|
||||
URL_GET_USER: URL_GET_USER_DIRECT,
|
||||
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
|
||||
};
|
||||
}
|
||||
|
||||
const { NEXT_PUBLIC_BASE_PATH } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||
const { BASE_PATH } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||
|
||||
function withBasePath(url: string) {
|
||||
return NEXT_PUBLIC_BASE_PATH + url;
|
||||
return BASE_PATH + url;
|
||||
}
|
||||
|
||||
return {
|
||||
BASE_PATH: NEXT_PUBLIC_BASE_PATH,
|
||||
BASE_PATH,
|
||||
URL_CRM_GRAPHQL: withBasePath(urls.URL_CRM_GRAPHQL_PROXY),
|
||||
URL_GET_USER: withBasePath(urls.URL_GET_USER_PROXY),
|
||||
URL_CORE_FINGAP: withBasePath(urls.URL_CORE_FINGAP_PROXY),
|
||||
|
||||
@ -14,7 +14,7 @@ const env = envSchema.parse(process.env);
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
||||
basePath: process.env.BASE_PATH,
|
||||
output: 'standalone',
|
||||
swcMinify: true,
|
||||
reactStrictMode: true,
|
||||
@ -31,15 +31,15 @@ const nextConfig = {
|
||||
return [
|
||||
{
|
||||
source: urls.URL_CRM_GRAPHQL_PROXY,
|
||||
destination: env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
destination: env.URL_CRM_GRAPHQL_DIRECT,
|
||||
},
|
||||
{
|
||||
source: urls.URL_GET_USER_PROXY,
|
||||
destination: env.NEXT_PUBLIC_URL_GET_USER_DIRECT,
|
||||
destination: env.URL_GET_USER_DIRECT,
|
||||
},
|
||||
{
|
||||
source: urls.URL_CORE_FINGAP_PROXY,
|
||||
destination: env.NEXT_PUBLIC_URL_CORE_FINGAP_DIRECT,
|
||||
destination: env.URL_CORE_FINGAP_DIRECT,
|
||||
},
|
||||
];
|
||||
},
|
||||
@ -49,9 +49,7 @@ const nextConfig = {
|
||||
|
||||
const plugins = [withLess, withGraphQL];
|
||||
|
||||
const colorPrimary = env.NEXT_PUBLIC_USE_DEV_COLORS
|
||||
? COLORS_DEV.COLOR_PRIMARY
|
||||
: COLORS_PROD.COLOR_PRIMARY;
|
||||
const colorPrimary = env.USE_DEV_COLORS ? COLORS_DEV.COLOR_PRIMARY : COLORS_PROD.COLOR_PRIMARY;
|
||||
|
||||
const config = {
|
||||
...nextConfig,
|
||||
|
||||
@ -35,7 +35,7 @@ export default class MyDocument extends Document {
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Лизинговый калькулятор Эволюция" />
|
||||
<link rel="icon" href={process.env.NEXT_PUBLIC_FAVICON} crossOrigin="use-credentials" />
|
||||
<link rel="icon" href={process.env.FAVICON} crossOrigin="use-credentials" />
|
||||
<link rel="apple-touch-icon" href="logo-100.png" crossOrigin="use-credentials" />
|
||||
</Head>
|
||||
<body>
|
||||
|
||||
@ -3,10 +3,10 @@ import { publicRuntimeConfigSchema } from '../config/schema/runtime-config';
|
||||
import { COLORS_DEV, COLORS_PROD } from '../constants/colors';
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const { NEXT_PUBLIC_USE_DEV_COLORS } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||
const { USE_DEV_COLORS } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||
|
||||
export default function getColors() {
|
||||
if (NEXT_PUBLIC_USE_DEV_COLORS) {
|
||||
if (USE_DEV_COLORS) {
|
||||
return COLORS_DEV;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user