By Harsha MV
We are building a Saas App in React and we want to emulate subdomains so that we can be sure that it does not break in staging or production server.
Since we do not use Apache while trying to test the React app. Which is the best way to implement the subdomains for it to make it work with React Development at http://localhost:3000 with a mapped domain and subdomain of product.local.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
Are you planning to use another web server like Nginx? You can host multiple applications on the droplet but you’ll need a web server like Nginx to set up your virtual hosts
To work with subdomains in your React app during development, you can use a combination of a local server like nginx and modify your hosts file. An example configuration will be:
- server {
- listen 80;
- server_name product.local;
- location / {
- proxy_pass http://localhost:3000;
- proxy_set_header Host $host;
- }
- }
For more information on setting up subdomains with DigitalOcean, you can check out our Nginx Server Blocks guide.
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.