chore: Centralize environment detection

This commit is contained in:
Tom Moor
2023-11-09 09:13:50 -05:00
parent 096a65b0f9
commit a1b52e18dd
9 changed files with 37 additions and 31 deletions

View File

@@ -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(