0
My application has a login repository, very simple with pure javascript, at most a jquery.
How do I make an ajax call by passing the correct url according to the environment I’m in? If I’m in the development environment, I want to use localhost. If I’m in the approval environment, I want to use Heroku.
I thought about using dotenv to manipulate this, but since I’m using pure javascript, I can’t give a require("dotenv").
Any suggestions?
I took a closer look at your response and it would actually work if the api ran on the same web port. In my case, the api runs on one port, the webapp runs on another port and the login runs on another port. They’re different repositories on github and run separately.
– Guilherme Nass
I understood what if you try to have a url per service: var getUrlLogin = window.location.host + ':8000' + '/api/login';
– vladwoguer
It would be an option too. I analyzed and solved this problem with nodejs same. In my index.js, I gave a require("dotenv") and let the file settings . env resolve according to the environment. Thanks for the help!
– Guilherme Nass