Solved

Different Env API end points AngularJS

Posted on 2014-11-18
2
100 Views
Last Modified: 2014-12-09
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
Comment
Question by:rbhargaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40451243
why not a server side variable ?
0
 

Author Comment

by:rbhargaw
ID: 40451280
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

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question