feat: rename to ALLOWED_PUBLIC_URL
This commit is contained in:
@@ -19,12 +19,18 @@ import { capture } from "./utils/analytics";
|
|||||||
import swaggerUi from 'swagger-ui-express';
|
import swaggerUi from 'swagger-ui-express';
|
||||||
import swaggerSpec from './swagger/config';
|
import swaggerSpec from './swagger/config';
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const allowedOrigin = isProduction ? process.env.ALLOWED_ORIGIN : '*';
|
const allowedOrigin = isProduction ? process.env.ALLOWED_PUBLIC_URL : '*';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors({
|
app.use(cors({
|
||||||
origin: 'http://localhost:5173',
|
origin: (origin, callback) => {
|
||||||
credentials: true,
|
if (!isProduction || origin === allowedOrigin || allowedOrigin === '*') {
|
||||||
|
callback(null, true); // Allow all in development or match production origin
|
||||||
|
} else {
|
||||||
|
callback(new Error('Not allowed by CORS')); // Block unexpected origins in production
|
||||||
|
}
|
||||||
|
},
|
||||||
|
credentials: true, // Include credentials if needed
|
||||||
}));
|
}));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user