Questions tagged «flask-restless»

8
当我的JavaScript代码出现时,为什么Postman不会出现“在请求的资源上没有'Access-Control-Allow-Origin'标头”错误?
注释:这个问题是关于为什么Postman不受XMLHttpRequest一样的CORS限制。此问题不是关于如何解决“无'Access-Control-Allow-Origin'...”错误。 请停止发布: 阳光下每种语言/框架的CORS配置。而是找到您相关的语言/框架的问题。 允许绕过CORS的请求的第三方服务 用于关闭各种浏览器的CORS的命令行选项 我正在尝试通过连接到内置的RESTful API Flask使用JavaScript进行授权。但是,当我发出请求时,出现以下错误: XMLHttpRequest无法加载http:// myApiUrl / login。所请求的资源上没有“ Access-Control-Allow-Origin”标头。因此,不允许访问原始“空”。 我知道API或远程资源必须设置标头,但是当我通过Chrome扩展程序Postman发出请求时,为什么它可以工作? 这是请求代码: $.ajax({ type: "POST", dataType: 'text', url: api, username: 'user', password: 'pass', crossDomain : true, xhrFields: { withCredentials: true } }) .done(function( data ) { console.log("done"); }) .fail( function(xhr, textStatus, errorThrown) { alert(xhr.responseText); alert(textStatus); });
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.