superagent always send data by OPTIONS method
See original GitHub issuerequest
.get(url)
.end(function (err, res) {
if (err) {
console.log(url);
console.log(err);
} else {
var data = res.body;
callback(data, ctx);
}
});
I always get this response
Request Method:OPTIONS Status Code:405 METHOD NOT ALLOWED
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
superagent always send data by OPTIONS method · Issue #692
When you make a request to another origin (URL with a different host/port/protocol than the page, i.e. generally absolute URL instead of a ......
Read more >Using .send() with SuperAgent request.post() makes General ...
But when I changed .query() to .send() to pass the input values as form-data instead of query-string-parameters, the Request Method was changed ...
Read more >A Complete Guide to Making HTTP Requests in Node.js
This article will discuss more on HTTP, HTTP requests, ways to make this requests in Node and how we can handle errors.
Read more >node_modulesold/superagent/docs - GitLab
To send the data as application/x-www-form-urlencoded simply invoke .type() with "form", where the default is "json". This request will POST the body "name= ......
Read more >Javascript – How to send a request with superagent that uses the ...
I am trying to make a request against a php server that is constructing the url like this: website.com/?q=help&q=moreHelp&q=evenMoreHelp.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you’re making request in the browser, the OPTIONS request (called preflight) is done by the browser, not by superagent. Superagent can’t do anything about it. Superagent can’t even detect when it’s happening, and that’s by design. See CORS:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
When you make a request to another origin (URL with a different host/port/protocol than the page, i.e. generally absolute URL instead of a relative path) you have to deal with CORS. This is mandatory for security, and you’ll most likely need to implement appropriate response on the server. There are exceptions for “simple” GET requests, but POSTing or GET with custom HTTP headers will make browser send another OPTIONS request first to check if these extra features are allowed by the server.
sorry, I doubled checked, not an issue with superagent, just the browser’s CORS strategy.