From 9452d4fd3321148fb80b64a67bd9983fee6c208e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Jul 2022 15:44:14 +0200 Subject: /!\ Use a dedicated config file for development It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updated --- server/controllers/api/oauth-clients.ts | 3 ++- server/controllers/plugins.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts index 2d847bdc1..eb7942fd6 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/controllers/api/oauth-clients.ts @@ -1,4 +1,5 @@ import express from 'express' +import { isTestOrDevInstance } from '@server/helpers/core-utils' import { OAuthClientModel } from '@server/models/oauth/oauth-client' import { HttpStatusCode, OAuthClientLocal } from '@shared/models' import { logger } from '../../helpers/logger' @@ -22,7 +23,7 @@ async function getLocalClient (req: express.Request, res: express.Response, next } // Don't make this check if this is a test instance - if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) { + if (!isTestOrDevInstance() && req.get('host') !== headerHostShouldBe) { logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe) return res.fail({ status: HttpStatusCode.FORBIDDEN_403, diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts index 28fffc9e1..51db1ad89 100644 --- a/server/controllers/plugins.ts +++ b/server/controllers/plugins.ts @@ -5,7 +5,7 @@ import { optionalAuthenticate } from '@server/middlewares/auth' import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' import { HttpStatusCode } from '../../shared/models/http/http-error-codes' import { PluginType } from '../../shared/models/plugins/plugin.type' -import { isTestInstance } from '../helpers/core-utils' +import { isProdInstance } from '../helpers/core-utils' import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' import { PluginManager, RegisteredPlugin } from '../lib/plugins/plugin-manager' import { getExternalAuthValidator, getPluginValidator, pluginStaticDirectoryValidator } from '../middlewares/validators/plugins' @@ -13,7 +13,7 @@ import { serveThemeCSSValidator } from '../middlewares/validators/themes' const sendFileOptions = { maxAge: '30 days', - immutable: !isTestInstance() + immutable: isProdInstance() } const pluginsRouter = express.Router() -- cgit v1.2.3