I'm using javascript to fetch some data with the fetch()
method:
fetch(url, {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: myHeaders,
referrer: 'no-referrer',
}
However it is giving me the following error:
Error:- Access to fetch at '.jpg?raw=1' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
What am I missing?
I'm using javascript to fetch some data with the fetch()
method:
fetch(url, {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: myHeaders,
referrer: 'no-referrer',
}
However it is giving me the following error:
Error:- Access to fetch at 'https://www.dropbox./s/v2pca6kq8nsqmso/abb5c48dae55560e4ae7d41af7bfdc50.jpg?raw=1' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
What am I missing?
Share edited Jul 3, 2020 at 17:01 Braiam 4,49611 gold badges49 silver badges83 bronze badges asked Jul 3, 2020 at 14:59 jai Bjai B 111 silver badge1 bronze badge 2-
What happens when you set
mode: 'cors',
tomode: 'no-cors',
as stated in the error message? – Chiel Commented Jul 3, 2020 at 15:43 - 1 [Cross-linking for reference: dropboxforum./t5/Dropbox-API-Support-Feedback/… ] – Greg Commented Jul 6, 2020 at 16:38
1 Answer
Reset to default 8www.dropbox. doesn't allow CORS. It doesn't include the CORS headers. This is intentional.
You can use the CDN link at domain dl.dropboxusercontent. instead, which does.
Note that this kind of usage is not supported by DropBox and may or may not be discontinued or changed without notice.
fetch('https://dl.dropboxusercontent./s/v2pca6kq8nsqmso/abb5c48dae55560e4ae7d41af7bfdc50.jpg?raw=1', {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: {},
referrer: 'no-referrer',
}).then(x => x.blob().then(y => console.log(y)))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745050578a4608360.html
评论列表(0条)