Send headers from the post via webpack proxy
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 |
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 '18 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?
– Beforeu
Nov 21 '18 at 14:40
add a comment |
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 '18 at 14:11
BeforeuBeforeu
154
154
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 '18 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?
– Beforeu
Nov 21 '18 at 14:40
add a comment |
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 '18 at 14:33
are you getting response of :{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?
– Beforeu
Nov 21 '18 at 14:40
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 '18 at 14:33
It should work without mentioning inside the proxy configuration, I have tried this.
– ashish pal
Nov 21 '18 at 14:33
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?– Beforeu
Nov 21 '18 at 14:40
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?– Beforeu
Nov 21 '18 at 14:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
0
active
oldest
votes
0
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.
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 '18 at 14:33
are you getting response of :
{error: "invalid_token", error_description: "Invalid access token"}
or just log in prompt?– Beforeu
Nov 21 '18 at 14:40