Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference POSTMAN and Javascript sending header #137

Open
faruk-redzic-sn opened this issue May 26, 2018 · 3 comments
Open

Difference POSTMAN and Javascript sending header #137

faruk-redzic-sn opened this issue May 26, 2018 · 3 comments

Comments

@faruk-redzic-sn
Copy link

faruk-redzic-sn commented May 26, 2018

Hello,
When I add header using Postman everything goes fine, but when I'm using javascript(fetch) I don't get added header on server side after request is handled. What am I missing?

@Jark
Copy link
Collaborator

Jark commented May 26, 2018

Hi faruk,

This doesn't sound like a problem in restup to me.

Can you provide me with a test case where restup doesn't do something that it should?

Jark

@f4rukr
Copy link

f4rukr commented May 26, 2018

Hello Jark,
Thank you for your response.
This is my code which I've written in Vue.js using fetch.
requestMethod(url) {
fetch(url, {
method: 'post',
headers: new Headers({
'Authorization': this.token
})
});
}
I don't get my added headers on server side after request is parsed from stream. Only the default once which are defined on restup. Am I missing something?
Regards

@Jark
Copy link
Collaborator

Jark commented May 28, 2018

Hi Faruk,

Where is the JavaScript hosted?

If the domain of where restup is running is different to the domain that you are sending in the request from (like localhost or some external site), you'll need to take cors into account.

From reading this: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch, it seems you will need to set mode: cors if you're doing any cross site scripting.

And you'll need to (most likely) set withCredentials: true as well to ensure cookies and I think authorization headers

I would compare the request from Post man and the request you're sending yourself using the chrome dev tools and see where the difference lies.

Hope the above helps, I don't have time right now to set up a test case using restup, but will have a bit more time later this week if the above is not helpful to you.

Regards,

Jark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants