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 #15

Closed Sidharth-Singh10 closed 1 day ago

Sidharth-Singh10 commented 1 day ago

hey @sparshg

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://example.com,http://localhost:3000,yourec2instance"

sparshg commented 1 day ago

Thanks!

Sidharth-Singh10 commented 1 day ago

Hey @sparshg , Would it be ok if you were to merge the PR on the 1st of October?. I want it to be counted as a Hacktoberfest contribution

sparshg commented 1 day ago

The PR would have been counted as out of bounds anyways since this was created before 1st Oct. See here

Sidharth-Singh10 commented 1 day ago

My bad, thanks for the info!!!