Javascript - Configuration of url's according to environment

0

My application has a very simple login repository with pure javascript, at most one jquery.

How do I make an ajax call by passing the correct url according to the environment I am? If I am in the development environment, I want to use localhost. If I am in the homologation environment, I want to use Heroku.

I thought of using dotenv to handle this, but as I'm using pure javascript, I can not give a require ("dotenv").

Any suggestions?

    
asked by anonymous 10.08.2018 / 03:39

1 answer

1

Use the location.

    var getUrl = window.location.host + '/api/login';
    
10.08.2018 / 04:55