angular proxy the same endpoint with different domains
up vote
0
down vote
favorite
Hey I have a angular client which wants to proxy the http request to different api servers. The issue is that I have two different servers:
10.0.0.1:8080
10.0.0.2:8080
Both the servers has the same endpoint, let's say, /api/v1/
When I call a http request to /api/v1/ how do I specify which server to go ?
I dont' want to call domain plus endpoint directly. Because that may raise the CORS problem.
------------------------------------------update-----------------------------------------------
Inspired by @Arne, I decide to use the following method:
"/server1": {
"target": "http://10.0.0.1:8080",
"secure": false,
"pathRewrite": {"^/server1" : ""}
},
"/server2": {
"target": "http://10.0.0.2:8080",
"secure": false,
"pathRewrite": {"^/server2" : ""}
}
every time I call a request /server1/api/v1/, it'll be proxied to 10.0.0.1:8080/api/v1
angular proxy
add a comment |
up vote
0
down vote
favorite
Hey I have a angular client which wants to proxy the http request to different api servers. The issue is that I have two different servers:
10.0.0.1:8080
10.0.0.2:8080
Both the servers has the same endpoint, let's say, /api/v1/
When I call a http request to /api/v1/ how do I specify which server to go ?
I dont' want to call domain plus endpoint directly. Because that may raise the CORS problem.
------------------------------------------update-----------------------------------------------
Inspired by @Arne, I decide to use the following method:
"/server1": {
"target": "http://10.0.0.1:8080",
"secure": false,
"pathRewrite": {"^/server1" : ""}
},
"/server2": {
"target": "http://10.0.0.2:8080",
"secure": false,
"pathRewrite": {"^/server2" : ""}
}
every time I call a request /server1/api/v1/, it'll be proxied to 10.0.0.1:8080/api/v1
angular proxy
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hey I have a angular client which wants to proxy the http request to different api servers. The issue is that I have two different servers:
10.0.0.1:8080
10.0.0.2:8080
Both the servers has the same endpoint, let's say, /api/v1/
When I call a http request to /api/v1/ how do I specify which server to go ?
I dont' want to call domain plus endpoint directly. Because that may raise the CORS problem.
------------------------------------------update-----------------------------------------------
Inspired by @Arne, I decide to use the following method:
"/server1": {
"target": "http://10.0.0.1:8080",
"secure": false,
"pathRewrite": {"^/server1" : ""}
},
"/server2": {
"target": "http://10.0.0.2:8080",
"secure": false,
"pathRewrite": {"^/server2" : ""}
}
every time I call a request /server1/api/v1/, it'll be proxied to 10.0.0.1:8080/api/v1
angular proxy
Hey I have a angular client which wants to proxy the http request to different api servers. The issue is that I have two different servers:
10.0.0.1:8080
10.0.0.2:8080
Both the servers has the same endpoint, let's say, /api/v1/
When I call a http request to /api/v1/ how do I specify which server to go ?
I dont' want to call domain plus endpoint directly. Because that may raise the CORS problem.
------------------------------------------update-----------------------------------------------
Inspired by @Arne, I decide to use the following method:
"/server1": {
"target": "http://10.0.0.1:8080",
"secure": false,
"pathRewrite": {"^/server1" : ""}
},
"/server2": {
"target": "http://10.0.0.2:8080",
"secure": false,
"pathRewrite": {"^/server2" : ""}
}
every time I call a request /server1/api/v1/, it'll be proxied to 10.0.0.1:8080/api/v1
angular proxy
angular proxy
edited Nov 22 at 3:45
asked Nov 21 at 22:01
debuglife
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You could proxy any alias in whatever server you're using it's proxy config. So you could proxy /server1 to 10.0.0.1:8080/api/v1/ and /server2 to 10.0.0.2:8080/api/v1/. Which server are you using?
you mean give an alias/server1to the server10.0.0.1:8080and rewrite the path right? just like this: rewrite/server1with/api/v1/
– debuglife
Nov 22 at 3:12
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You could proxy any alias in whatever server you're using it's proxy config. So you could proxy /server1 to 10.0.0.1:8080/api/v1/ and /server2 to 10.0.0.2:8080/api/v1/. Which server are you using?
you mean give an alias/server1to the server10.0.0.1:8080and rewrite the path right? just like this: rewrite/server1with/api/v1/
– debuglife
Nov 22 at 3:12
add a comment |
up vote
0
down vote
You could proxy any alias in whatever server you're using it's proxy config. So you could proxy /server1 to 10.0.0.1:8080/api/v1/ and /server2 to 10.0.0.2:8080/api/v1/. Which server are you using?
you mean give an alias/server1to the server10.0.0.1:8080and rewrite the path right? just like this: rewrite/server1with/api/v1/
– debuglife
Nov 22 at 3:12
add a comment |
up vote
0
down vote
up vote
0
down vote
You could proxy any alias in whatever server you're using it's proxy config. So you could proxy /server1 to 10.0.0.1:8080/api/v1/ and /server2 to 10.0.0.2:8080/api/v1/. Which server are you using?
You could proxy any alias in whatever server you're using it's proxy config. So you could proxy /server1 to 10.0.0.1:8080/api/v1/ and /server2 to 10.0.0.2:8080/api/v1/. Which server are you using?
answered Nov 21 at 23:45
Arne
514212
514212
you mean give an alias/server1to the server10.0.0.1:8080and rewrite the path right? just like this: rewrite/server1with/api/v1/
– debuglife
Nov 22 at 3:12
add a comment |
you mean give an alias/server1to the server10.0.0.1:8080and rewrite the path right? just like this: rewrite/server1with/api/v1/
– debuglife
Nov 22 at 3:12
you mean give an alias
/server1 to the server 10.0.0.1:8080 and rewrite the path right? just like this: rewrite /server1 with /api/v1/– debuglife
Nov 22 at 3:12
you mean give an alias
/server1 to the server 10.0.0.1:8080 and rewrite the path right? just like this: rewrite /server1 with /api/v1/– debuglife
Nov 22 at 3:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421066%2fangular-proxy-the-same-endpoint-with-different-domains%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown