Send headers from the post via webpack proxy
up vote
0
down vote
favorite
Hi i have a request that i want to send via proxy to handle CORS but unfortunatelly when i use proxy, headers are dissapearing.
postOrder(){
this.http.post('/payu/order',this.request, {
headers:{
"Content-Type": "application/json",
"Authorization" : "Bearer 8a424394-36aa-47a0-ac8c-5f48304e25aa"
}
}).subscribe(response => console.log(response))
}
this is my post
{
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
}
}
And there is proxy.conf.json
I have found that headers inside post are not being sent by proxy so the walk around is to send headers inside proxy like that:
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
"headers": {
"Content-Type": "application/json",
"Authorization" : "Bearer 1c208fe3-072f-4de5-a681-6a179952cafe"
}
}
Is there any way to make proxy accept headers from the post, or set Authorization header inside proxy as a parameter? Or maybe there is any other way to get rid of CORS problem than using proxy.
angular rest webpack webpack-dev-server
add a comment |
up vote
0
down vote
favorite
Hi i have a request that i want to send via proxy to handle CORS but unfortunatelly when i use proxy, headers are dissapearing.
postOrder(){
this.http.post('/payu/order',this.request, {
headers:{
"Content-Type": "application/json",
"Authorization" : "Bearer 8a424394-36aa-47a0-ac8c-5f48304e25aa"
}
}).subscribe(response => console.log(response))
}
this is my post
{
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
}
}
And there is proxy.conf.json
I have found that headers inside post are not being sent by proxy so the walk around is to send headers inside proxy like that:
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
"headers": {
"Content-Type": "application/json",
"Authorization" : "Bearer 1c208fe3-072f-4de5-a681-6a179952cafe"
}
}
Is there any way to make proxy accept headers from the post, or set Authorization header inside proxy as a parameter? Or maybe there is any other way to get rid of CORS problem than using proxy.
angular rest webpack webpack-dev-server
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}or just log in prompt?
– Beforeu
Nov 21 at 14:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hi i have a request that i want to send via proxy to handle CORS but unfortunatelly when i use proxy, headers are dissapearing.
postOrder(){
this.http.post('/payu/order',this.request, {
headers:{
"Content-Type": "application/json",
"Authorization" : "Bearer 8a424394-36aa-47a0-ac8c-5f48304e25aa"
}
}).subscribe(response => console.log(response))
}
this is my post
{
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
}
}
And there is proxy.conf.json
I have found that headers inside post are not being sent by proxy so the walk around is to send headers inside proxy like that:
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
"headers": {
"Content-Type": "application/json",
"Authorization" : "Bearer 1c208fe3-072f-4de5-a681-6a179952cafe"
}
}
Is there any way to make proxy accept headers from the post, or set Authorization header inside proxy as a parameter? Or maybe there is any other way to get rid of CORS problem than using proxy.
angular rest webpack webpack-dev-server
Hi i have a request that i want to send via proxy to handle CORS but unfortunatelly when i use proxy, headers are dissapearing.
postOrder(){
this.http.post('/payu/order',this.request, {
headers:{
"Content-Type": "application/json",
"Authorization" : "Bearer 8a424394-36aa-47a0-ac8c-5f48304e25aa"
}
}).subscribe(response => console.log(response))
}
this is my post
{
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
}
}
And there is proxy.conf.json
I have found that headers inside post are not being sent by proxy so the walk around is to send headers inside proxy like that:
"/payu/order": {
"target": "https://secure.payu.com/api/v2_1/orders",
"changeOrigin": true,
"headers": {
"Content-Type": "application/json",
"Authorization" : "Bearer 1c208fe3-072f-4de5-a681-6a179952cafe"
}
}
Is there any way to make proxy accept headers from the post, or set Authorization header inside proxy as a parameter? Or maybe there is any other way to get rid of CORS problem than using proxy.
angular rest webpack webpack-dev-server
angular rest webpack webpack-dev-server
asked Nov 21 at 14:11
Beforeu
154
154
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}or just log in prompt?
– Beforeu
Nov 21 at 14:40
add a comment |
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}or just log in prompt?
– Beforeu
Nov 21 at 14:40
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"} or just log in prompt?– Beforeu
Nov 21 at 14:40
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"} or just log in prompt?– Beforeu
Nov 21 at 14:40
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53413974%2fsend-headers-from-the-post-via-webpack-proxy%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
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 at 14:33
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"}or just log in prompt?– Beforeu
Nov 21 at 14:40