I'm running both the front-end (React) and back-end (nodejs) on the same linux server.
In my front-end, I have a fetch
request to the back-end which I have to specify as fetch('http://10.25.248.238:3001/')
, the IP (local because this site is for internal company use) and port of the back-end.
Is there a way to avoid hardcoding this back-end IP address so that it still works if both the front-end and back-end gets moved to another server?
I have tried http://localhost:3001
but that actually tries to fetch from the localhost of the visitors of the website. fetch('/')
didn't work either.
Registering a domain name is not appropriate as this site is only meant for internal use.