chore: Centralize environment detection
This commit is contained in:
@@ -22,8 +22,6 @@ import routes from "../routes";
|
||||
import api from "../routes/api";
|
||||
import auth from "../routes/auth";
|
||||
|
||||
const isProduction = env.ENVIRONMENT === "production";
|
||||
|
||||
// Construct scripts CSP based on services in use by this installation
|
||||
const defaultSrc = ["'self'"];
|
||||
const scriptSrc = ["'self'", "gist.github.com", "www.googletagmanager.com"];
|
||||
@@ -36,7 +34,7 @@ if (env.isCloudHosted) {
|
||||
}
|
||||
|
||||
// Allow to load assets from Vite
|
||||
if (!isProduction) {
|
||||
if (!env.isProduction) {
|
||||
scriptSrc.push(env.URL.replace(`:${env.PORT}`, ":3001"));
|
||||
scriptSrc.push("localhost:3001");
|
||||
}
|
||||
@@ -54,7 +52,7 @@ if (env.CDN_URL) {
|
||||
export default function init(app: Koa = new Koa(), server?: Server) {
|
||||
void initI18n();
|
||||
|
||||
if (isProduction) {
|
||||
if (env.isProduction) {
|
||||
// Force redirect to HTTPS protocol unless explicitly disabled
|
||||
if (env.FORCE_HTTPS) {
|
||||
app.use(
|
||||
|
||||
Reference in New Issue
Block a user