fix: log production status at startup
This commit is contained in:
parent
19dd59505b
commit
bdbb421377
2 changed files with 17 additions and 17 deletions
|
@ -20,6 +20,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|||
dotenv.config({ path: '.env' });
|
||||
}
|
||||
|
||||
console.log('Production => ', process.env.NODE_ENV === 'production');
|
||||
|
||||
const {
|
||||
LOGS_FOLDER = 'logs',
|
||||
LOGS_APP = 'app.log',
|
||||
|
|
|
@ -15,24 +15,22 @@ import datasource from './config/datasource';
|
|||
import appsService from './modules/apps/apps.service';
|
||||
import { runUpdates } from './core/updates/run';
|
||||
|
||||
let corsOptions = {};
|
||||
let corsOptions = __prod__
|
||||
? {
|
||||
credentials: true,
|
||||
origin: function (origin: any, callback: any) {
|
||||
// disallow requests with no origin
|
||||
if (!origin) return callback(new Error('Not allowed by CORS'), false);
|
||||
|
||||
if (__prod__) {
|
||||
corsOptions = {
|
||||
credentials: true,
|
||||
origin: function (origin: any, callback: any) {
|
||||
// disallow requests with no origin
|
||||
if (!origin) return callback(new Error('Not allowed by CORS'), false);
|
||||
if (config.CLIENT_URLS.includes(origin)) {
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
if (config.CLIENT_URLS.includes(origin)) {
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
const message = "The CORS policy for this origin doesn't allow access from the particular origin.";
|
||||
return callback(new Error(message), false);
|
||||
},
|
||||
};
|
||||
}
|
||||
const message = "The CORS policy for this origin doesn't allow access from the particular origin.";
|
||||
return callback(new Error(message), false);
|
||||
},
|
||||
}
|
||||
: {};
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
|
@ -71,7 +69,7 @@ const main = async () => {
|
|||
httpServer.listen(port, () => {
|
||||
// Start apps
|
||||
appsService.startAllApps();
|
||||
logger.info(`Server running on port ${port}`);
|
||||
logger.info(`Server running on port ${port} 🚀 Production => ${__prod__}`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
Loading…
Add table
Reference in a new issue