• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 114
  • Last Modified:

Different Env API end points AngularJS

I have Angular app which gets the data from Web API. Now to get the data normally I use below code

where API_URL is the location where the Web APIs are hosted.

What is the best way to maintain API_URL for different environment?

Like for Dev, API endpoint will be server1,   for QA , API endpoint will be in Server2 and prod will be server3
Is it just enough to have config.js and hardcode the server name based on environment?



$http.post(API_URL + "/PR", JSON.stringify(data), {
            headers: {
                'Content-Type': 'application/json'
            }
        }
        ).success(function (response) {

        }
        ).error(function (error) {
        });
0
rbhargaw
Asked:
rbhargaw
1 Solution
 
leakim971PluritechnicianCommented:
why not a server side variable ?
0
 
rbhargawFounderAuthor Commented:
If the client is in Server1 and  API is in Server2, the client atleast have to know server2 name or address to call the API. then how can we define server side variable?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now