问题
I am setting up a Localhost domain so it can communicate with this third-party API and Auth servers. For example, change 127.0.0.1 to local.example.com
local.example.com is the domain whitelisted with this third-party enterprise. I need to set this up so i can run API routes to it.
I was able to change 127.0.0.1 locally in C:\Windows\System32\drivers\etc\hosts file and now Node.js is running on it.
I added the webpack config devServer - host to local.example.com but the port is still there. I need to understand how to change this for react because right now it's porting to local.example.com:3000.
回答1:
I think you're almost there :-) The devServer
option has a port
property. Set that to 8080
or 80
. Restart your server. Then, open the browser and try leaving it off the URL
回答2:
After digging around, I found some solutions. Essential, my goal was to set http://localhost:3000 to http://local.example.com.
1. Add local.example.com to your hosts file (windows)
2. Set up your react port to 80
This would remove the 3000 on local.example.com:3000 to local.example.com
On HTTPS request, set the port to 443
This would result to https://local.example.com
来源:https://stackoverflow.com/questions/58898600/how-to-update-react-localhost-127-0-0-13000-to-another-domain-local-example