Repository navigation
Script Refresh Allowed Hosts
WSL2 assigns a dynamic IP to its virtual network adapter (eth0). This causes issues when trying to access services at http://localhost:8000/ running in WSL2 from the Windows host, as they aren't bound to localhost. Additionally, Django requires the server's IP to be listed in ALLOWED_HOSTS to respond to requests, rejecting others for security reasons. The script automates retrieving the current WSL2 IP and updating ALLOWED_HOSTS, ensuring seamless access to the application.
1. Configures the ALLOWED_HOSTS environment variable by:
- Removing any outdated
WSL2 IPaddresses from theALLOWED_HOSTS. - Adding the current
WSL2 IPaddress to theALLOWED_HOSTS.
2. The environment file in which the modifications are made is determined, based on the --deployment_mode (required) argument:
--deployment_mode=dev->config/envs/dev/the_wall_api_dev.env--deployment_mode=prod_v2->config/envs/prod/the_wall_api_prod.env
3. Outputs the current WSL2 IP address in the console, helping the user determine where the application is accessible.
📌 Notable Technical Sections
👤 Author
LinkedIn: Aleksandar Dimitrov
Yahoo: sasho_1983@yahoo.com