“如何处理标题”;“访问控制允许来源”;使用安培和rest集合?
正在尝试使用代码请求cors请求:“如何处理标题”;“访问控制允许来源”;使用安培和rest集合?,rest,ampersand-collection,Rest,Ampersand Collection,正在尝试使用代码请求cors请求: export default Collection.extend({ model: person, url () { return 'http://127.0.0.1:5000/person/' }, ajaxConfig: function () { return { headers: { 'Access-Control-Allow-Origin': 'http
export default Collection.extend({
model: person,
url () {
return 'http://127.0.0.1:5000/person/'
},
ajaxConfig: function () {
return {
headers: {
'Access-Control-Allow-Origin': 'http//:127.0.0.1:3000'
},
xhrFields: {
withCredentials: false
}
};
},
})
我正在使用http/:127.0.0.1:3000发送请求,但是如果使用http/:127.0.0.1:3000,我仍然会收到下面的错误
XMLHttpRequest cannot load http://127.0.0.1:5000/person/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
如何处理此类请求?您的集合不需要在其请求头中发送“Access-Control-Allow-Origin”:“http//:127.0.0.1:3000”,您的服务器at需要在其响应头中将其发送到飞行前请求 如果您能提供一些有关服务器设置的详细信息,我可以帮助您了解如何将头添加到响应中