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
Request Method: OPTIONS #51
Comments
OPTIONS is a crossorigin. https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS |
I think this Issue can be closed. This is how Browsers behave as @max107 pointed out. |
There is some wired think. When I remove line with: 'Content-Type': 'application/json' it works. So this is correct setup: import fetch from 'isomorphic-fetch'
fetch('http://localhost:3000/api/v1/sign_in', {
method: 'POST',
headers: {
'Accept': 'application/json'
},
body: {
login: 'test'
}
}) No OPTIONS request anymore. |
@14113 That worked for me, thanks. |
Removing the |
Also got this issue, but removing content-type won't help! |
sometimes, remove content-type caused modify server-end codes |
Not worked for me, and method options is random
|
@borm How do you mean random? You're getting OPTIONS because you have a custom header Token by the looks of it |
Does not work here either. Despite the fact I set the header to content-type: application/json, when fetching, this somehow gets changed to text... And my webservice will complain. Back to axios then... |
We are having the same issue as well. We have to have the content-type header, so this lib won't work for us |
I can confirm this is working properly even with the import fetch from 'isomorphic-fetch';
const productId = 1;
const data = {description: 'An updated product description!'};
const res = await fetch(
`https://my-api.com/product/${productId}`,
{
method: 'PUT',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
const data = await res.json(); After implementing support for CORS requests on my server, I was still getting tripped up for a bit because the Chrome network tab was only listing the OPTIONS request, however my Apache logs showed two requests, OPTIONS followed by PUT as expected... I was about to file a bug with Chrome, however, I realized that after unchecking the XHR filter in the network tab, my PUT request became visible. Feels like a Chromism (read: bug)... Seems the PUT request does not count as XHR in the network tab's eyes, despite the fact all the GET requests I've sent through this library do, LOL. (Maybe something funky with the pre-flight flow inside the browser). Still though, FWIW, isomorphic-fetch is working as expected in this regard AFAICT. |
removing content type worked for me, but i'm also going to investigate setting up the cors headers properly. ATM just setting it in apache to test. |
I'm trying to make a POST request but I'm still sending OPTIONS as a 'Request Method'.
Example:
In Chrome, I can see:
Remote Address:127.0.0.1:3000
Request URL:http://localhost:3000/api/v1/sign_in
Request Method:OPTIONS
Status Code:404 Not Found
Thanks in advance.
The text was updated successfully, but these errors were encountered: