亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - CORS header missing in fetch's GET request 'Access-Control-Allow-Origin'
巴扎黑
巴扎黑 2017-06-12 09:23:04
0
2
1201

Does the server have to set the 'Access-Control-Allow-Origin' parameter in the response header when responding to the fetch GET request?

This is Yiban’s API, not my server

No problem when making requests on the browser

I checked several information and found that it was of no use

This is the code for my get request

function request_get(url) {
    return fetch(url, {
        credentials: 'include',
    }).then(function(response) {
        return response.json()
    })
}
巴扎黑
巴扎黑

reply all(2)
小葫蘆

This problem is caused by the same-origin policy of the browser, and there are several solutions:

  1. JSONP

  2. CORS

  3. Use Nginx or Express static resource server for network proxy configuration, and simulate the local and remote sources as the same origin for data pulling

世界只因有你

This means that the API you requested is not in the same domain as your page. If the API does not set the Access-Control-Allow-Origin field, it means that it is not an API interface that supports cross-domain access. When writing Fetch logic on a page, no matter how the request header is customized, it will also be intercepted by the browser (before fetch, the browser will initiate a preflight OPTIONS request and determine whether fetch is allowed based on the header field of the response. At this time, the browser determines The API does not support cross-domain, so the request is intercepted for security reasons).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template