Skip to content

Commit 9fdaf14

Browse files
committed
Allow CORS from nexus-tool.com
1 parent edb99d3 commit 9fdaf14

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

backend/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ WORKDIR /app
1717
ENV NODE_ENV="production"
1818
ENV BACKEND_URL="https://mindmeld-87770296075.europe-west1.run.app"
1919
ENV PORT=3000
20-
ENV FRONTEND_URL="https://mindmeldtool.netlify.app"
20+
ENV FRONTEND_URLS="https://mindmeldtool.netlify.app,https://nexus-tool.com"
2121
ENV CLOUD_SQL_CONNECTION_NAME="mindmeld-backend:europe-west1:mindmeld-db"
2222

2323
COPY package*.json ./
@@ -26,4 +26,4 @@ RUN npm ci --only=production
2626
COPY --from=builder /app/dist ./dist
2727

2828
EXPOSE 3000
29-
CMD ["node", "dist/index.js"]
29+
CMD ["node", "dist/index.js"]

backend/src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ interface Config {
22
nodeEnv: string;
33
port: number;
44
backendUrl: string;
5-
frontendUrl: string;
5+
frontendUrls: string[];
66
openAIKey: string;
77
googleClientId: string;
88
db: {
@@ -33,7 +33,7 @@ const config: Config = {
3333
nodeEnv: environment,
3434
port: parseInt(process.env.PORT || '3001', 10),
3535
backendUrl: process.env.BACKEND_URL || 'http://localhost',
36-
frontendUrl: process.env.FRONTEND_URL || 'http://localhost:3000',
36+
frontendUrls: (process.env.FRONTEND_URLS || 'http://localhost:3000').split(',').map(url => url.trim()),
3737
openAIKey: process.env.OPENAI_API_KEY || '',
3838
googleClientId: process.env.GOOGLE_CLIENT_ID || '',
3939
db: {
@@ -45,4 +45,4 @@ const config: Config = {
4545
},
4646
};
4747

48-
export default config;
48+
export default config;

backend/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const app = express();
1818
const server = http.createServer(app);
1919
const io = new Server(server, {
2020
cors: {
21-
origin: config.frontendUrl,
21+
origin: config.frontendUrls,
2222
methods: ["GET", "POST"]
2323
}
2424
});
@@ -100,5 +100,5 @@ io.on('connection', (socket) => {
100100
server.listen(config.port, () => {
101101
console.log(`Server running at ${config.backendUrl}:${config.port}`);
102102
console.log(`Environment: ${config.nodeEnv}`);
103-
console.log(`Allowing CORS for origin: ${config.frontendUrl}`);
103+
console.log(`Allowing CORS for origins: ${config.frontendUrls.join(', ')}`);
104104
});

0 commit comments

Comments
 (0)