fix: run DB migrations on startup, fix CORS for production
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -6,6 +6,7 @@ import dotenv from 'dotenv';
|
||||
import { errorHandler } from './middleware/errorHandler';
|
||||
import { notFound } from './middleware/notFound';
|
||||
import apiRoutes from './routes';
|
||||
import { runMigrations } from './db/migrate';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -15,7 +16,7 @@ const port = process.env.PORT || 3001;
|
||||
// Middleware
|
||||
app.use(helmet());
|
||||
app.use(cors({
|
||||
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
|
||||
origin: process.env.CORS_ORIGIN || ['http://localhost:5173', 'https://sm.jiosii.com'],
|
||||
credentials: true
|
||||
}));
|
||||
app.use(morgan('dev'));
|
||||
@@ -38,7 +39,8 @@ app.use('/api', apiRoutes);
|
||||
app.use(notFound);
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(port, () => {
|
||||
app.listen(port, async () => {
|
||||
await runMigrations();
|
||||
console.log(`⚡️ Server is running on port ${port}`);
|
||||
console.log(`🌍 Environment: ${process.env.NODE_ENV || 'development'}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user