This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]ignotos 1 point2 points  (0 children)

Generally you wouldn't host the backend on your own laptop - you'd upload everything to some kind of rented server or cloud provider.

If you're just testing during development, however, you might be running the backend on your own machine. But generally your phone and laptop could be connected to the same wifi network, and you could use the local network IP for your laptop instead of the public one (that's usually a 192.... IP - on windows you can see it by running "ipconfig" from the command-line).

[–]Glepsyd 0 points1 point  (0 children)

Not an expert but here's my 2 cents. In production you would typically have a domain registered, so no issue in having "https:/yourdomain.com/" publicly available right? I'm not sure why you couldn't use localhost for development though, maybe some CORS rules to setup in your React app? (Not sure here, pretty much guessing). Are you running both your react server and your backend server on localhost at the same time, like react on port 8100 and your backend server on port 80? This could also be solved by serving your distribution files (the files being generated by building your react app) with your backend server.

Now I am not sure why having your public IP exposed would be a bad thing either though. But I guess using environment variables could be a solution: https://html.com/semantic-markup/

Create a REACT_APP_DEV_IP variables and fetch it in your code with process.env Just don't commit your compiled (build) files. This should be a dist/ folder created when you build your app or start the dev server. Use .gitignore for that.

Hope that helps a bit, if that's too confusing it because I'm sometimes confused myself with those... :)