.env: fix web app variables names

This commit is contained in:
vchikalkin 2023-10-16 12:36:29 +03:00
parent 45d30e1263
commit 9dc49758fc
10 changed files with 38 additions and 24 deletions

12
.env
View File

@ -2,9 +2,9 @@ COMPOSE_PROJECT_NAME=
NETWORK_NAME=
# WEB
BASE_PATH=/login
TITLE=
DESCRIPTION=
APP_BASE_PATH=/login
APP_TITLE=
APP_DESCRIPTION=
# API
LDAP_BIND_DN=
@ -14,9 +14,9 @@ LDAP_URL=
LDAP_BASE=
LDAP_ATTRIBUTE=
SECRET=
TOKEN_TTL=
CACHE_TTL=
API_SECRET=
API_TOKEN_TTL=
API_CACHE_TTL=
REDIS_HOST=redis
REDIS_PORT=

View File

@ -17,9 +17,9 @@ import { JwtModule } from '@nestjs/jwt';
isGlobal: true,
}),
JwtModule.register({
secret: env.SECRET,
secret: env.API_SECRET,
signOptions: {
expiresIn: env.TOKEN_TTL,
expiresIn: env.API_TOKEN_TTL,
},
}),
AuthModule,

View File

@ -13,7 +13,7 @@ export class AuthController {
cookieOptions: { maxAge: number; path: string };
constructor(private readonly authService: AuthService) {
this.cookieOptions = {
maxAge: env.TOKEN_TTL,
maxAge: env.API_TOKEN_TTL,
path: '/',
};
}

View File

@ -2,7 +2,7 @@ import { z } from 'zod';
const envSchema = z.object({
API_PORT: z.number().optional().default(3001),
CACHE_TTL: z.string().transform((val) => Number.parseInt(val, 10)),
API_CACHE_TTL: z.string().transform((val) => Number.parseInt(val, 10)),
LDAP_ATTRIBUTE: z.string(),
LDAP_BASE: z.string(),
LDAP_BIND_CREDENTIALS: z.string(),
@ -14,8 +14,8 @@ const envSchema = z.object({
.string()
.transform((val) => Number.parseInt(val, 10))
.default('6379'),
SECRET: z.string(),
TOKEN_TTL: z.string().transform((val) => Number.parseInt(val, 10)),
API_SECRET: z.string(),
API_TOKEN_TTL: z.string().transform((val) => Number.parseInt(val, 10)),
});
export default envSchema;

View File

@ -15,7 +15,7 @@ async function bootstrap() {
);
await app.register(fastifyCookie, {
secret: env.SECRET,
secret: env.API_SECRET,
});
await app.listen(env.API_PORT, '0.0.0.0');

View File

@ -16,7 +16,7 @@ import { env } from 'src/config/env';
host: env.REDIS_HOST,
port: env.REDIS_PORT,
store: redisStore,
ttl: env.CACHE_TTL,
ttl: env.API_CACHE_TTL,
}),
LdapModule,
],

View File

@ -7,7 +7,7 @@ import Input from '@/elements/Input';
import axios from 'axios';
import { useState } from 'react';
const { BASE_PATH, APP_TITLE } = publicRuntimeConfig;
const { APP_BASE_PATH, APP_TITLE } = publicRuntimeConfig;
export default function Form() {
const [hasError, setHasError] = useState(false);
@ -27,7 +27,7 @@ export default function Form() {
.post('/signin', data)
.then(() => {
const url =
(window.location.pathname.replace(BASE_PATH, '') || '/') +
(window.location.pathname.replace(APP_BASE_PATH, '') || '/') +
(window.location.search || '');
window.location.replace(url);

View File

@ -3,7 +3,7 @@ import { z } from 'zod';
const envSchema = z.object({
APP_DESCRIPTION: z.string(),
APP_TITLE: z.string(),
BASE_PATH: z.string().optional().default(''),
APP_BASE_PATH: z.string().optional().default(''),
});
export default envSchema;

View File

@ -9,7 +9,7 @@ const runtimeConfig = envSchema.parse(process.env);
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: process.env.BASE_PATH,
basePath: process.env.APP_BASE_PATH,
eslint: {
ignoreDuringBuilds: true,
},

View File

@ -2,7 +2,7 @@
import { serverRuntimeConfig } from '@/config/runtime';
import Document, { Head, Html, Main, NextScript } from 'next/document';
const { BASE_PATH, APP_DESCRIPTION } = serverRuntimeConfig;
const { APP_BASE_PATH, APP_DESCRIPTION } = serverRuntimeConfig;
export default class MyDocument extends Document {
render() {
@ -11,11 +11,25 @@ export default class MyDocument extends Document {
<Head>
<meta charSet="utf-8" />
<meta name="description" content={APP_DESCRIPTION} />
<link rel="apple-touch-icon" sizes="120x120" href={`${BASE_PATH}/apple-touch-icon.png`} />
<link rel="icon" type="image/png" sizes="32x32" href={`${BASE_PATH}/favicon-32x32.png`} />
<link rel="icon" type="image/png" sizes="16x16" href={`${BASE_PATH}/favicon-16x16.png`} />
<link rel="manifest" href={`${BASE_PATH}/site.webmanifest`} />
<link rel="mask-icon" href={`${BASE_PATH}/safari-pinned-tab.svg`} color="#5bbad5" />
<link
rel="apple-touch-icon"
sizes="120x120"
href={`${APP_BASE_PATH}/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href={`${APP_BASE_PATH}/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href={`${APP_BASE_PATH}/favicon-16x16.png`}
/>
<link rel="manifest" href={`${APP_BASE_PATH}/site.webmanifest`} />
<link rel="mask-icon" href={`${APP_BASE_PATH}/safari-pinned-tab.svg`} color="#5bbad5" />
<meta name="msapplication-TileColor" content="#1c01a9" />
<meta name="theme-color" content="#ffffff" />
</Head>