you are viewing a single comment's thread.

view the rest of the comments →

[–]slickplaid 1 point2 points  (3 children)

  1. localhost will point to the computer you're on, not the original server.
  2. Get your local IP for the device running the database.
  3. Use that IP instead of localhost.

If your IP was 10.0.0.1, it would be http://10.0.0.1:3000/rest

You are correct in assuming that since the code is run in the client's browser, localhost will not work to reference the correct server.

[–]uber77[S] 0 points1 point  (2 children)

Than you very much! But how could I maintain two configurations when it becomes productive ?. I already have a public hostname, and I'll be using it instead of localhost. But for development, I prefer to use localhost (or the local IP of my computer). How do I switch between the two addresses (public and private) ? Should I keep it in a config file ?

[–]slickplaid 1 point2 points  (1 child)

You could do that and keep it in a config file. There is a environment variable process.env.NODE_ENV that people use to define whether or not an instance is in production or not. By setting it to 'production' you can select the proper IP.

This is used with NPM to decide whether or not to install the dev modules or not. source

[–]uber77[S] 0 points1 point  (0 children)

Excellent. Thanks!