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

Discussion about X-Requested-With header #21

Open
Vinorcola opened this issue Mar 23, 2017 · 3 comments
Open

Discussion about X-Requested-With header #21

Vinorcola opened this issue Mar 23, 2017 · 3 comments

Comments

@Vinorcola
Copy link

Hello,

Is there particullar reason why the X-Requested-With header is set only is request has a body?
(https://github.com/yanatan16/nanoajax/blob/master/index.js#L75)

Shouldn't the header be set for any non GET or HEAD request?

For example, if I'm making a DELETE request with no body, I think the header should be there... Currently, I have to add this header by hand.

I'm not very competent on that matter, so maybe I'm wrong... Please advise.

@bobrosoft
Copy link

I have another related issue: XMLHttpRequest cannot load **my_domain_here**. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers in preflight response.. I don't see any option in the code to exclude that header. Is it really needed?

@voxpelli
Copy link

X-Requested-With is an established practice for indicating that a request is an AJAX-request and has wide support among back-end frameworks and should be added to all requests (but as shown probably with a mechanism that makes it possible to opt-out from, but that @bobrosoft is a different issue than the main one here, so better to open a new issue where you just reference this one, else it may be lost in the conversation when the main issue has been dealt with)

@bobrosoft
Copy link

bobrosoft commented May 11, 2017

I know it's different, I said "related" :) We just faced it in comparison to Angular 2 Http service which not send that header so we hadn't that issues before, but now need to use nanoajax in one microlibrary. I will create issue and PR if have time later (if PRs merged here).

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