Skip to content

Conversation

@tusharnain
Copy link

Centralize CORS configuration for Express and Socket.IO using .env

Description

This pull request centralizes the CORS configuration for both Express and Socket.IO into a single reusable module.
It introduces environment-based origin management using the .env file for better flexibility across different environments.

Changes

  • Created src/config/cors.js to manage all CORS logic in one place
  • Added .env variable ALLOWED_ORIGINS for dynamic allowed origins
  • Applied shared CORS setup for both Express routes and Socket.IO
  • Updated server.js to use corsMiddleware() and socketCorsConfig
  • Improved maintainability, readability, and environment adaptability

Environment Variables

ALLOWED_ORIGINS=http://localhost:5173,https://guessync.netlify.app

@tusharnain
Copy link
Author

@yep-yogesh take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant