sparshg / battleship

Classic battleship game, two-player, online, deployed.
http://sparshg.dev/battleship/
MIT License
2 stars 5 forks source link

Updating CORS to be more restrictive #14

Closed Sidharth-Singh10 closed 1 day ago

Sidharth-Singh10 commented 1 day ago

Description

This PR adds support for configuring CORS allowed origins from the .env file. Instead of hardcoding the origins in the code, the backend can now dynamically read the origins from the environment, making it easier to manage in different environments (development, staging, production).

Changes:

  1. Reads the ALLOWED_ORIGINS variable from the .env file.
  2. Splits the comma-separated list of origins and parses them into a Vec<String>.
  3. Configures the CorsLayer with the parsed origins.

Example .env configuration:

     `ALLOWED_ORIGINS=http://localhost:3001,http://localhost:3000,yourec2instance`
Sidharth-Singh10 commented 1 day ago

check failed , closing the PR. Will open up a new PR after rectifying.

sparshg commented 1 day ago

You can just push new commit to your branch and this would have auto updated

Sidharth-Singh10 commented 1 day ago

Will keep in mind!!!