XMLHttpRequest 无法在 Ionic 登录到 odoo 服务器时加载 http://localhost:80
XMLHttpRequest cannot load http://localhost:8088/web/webclient/version_info error in ionic login to odoo server
当我尝试使用离子应用程序登录到odoo服务器时。我得到了下面引用的错误。如果是因为 CORS,如何在不使用 nginx 的情况下在本地 odoo 服务器中进行配置?
XMLHttpRequest cannot load http://localhost:8088/web/webclient/version_info. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
默认情况下,出于安全原因,浏览器会阻止跨域请求,但我们可以通过以下方式实现跨域请求工作。
打开Chrome并安装此插件并在其上,然后尝试发送请求它将起作用,但这不是一个好主意。
https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-ntp-icon
第二个想法
最好的办法是转到中间件并将标头添加为
"访问控制允许来源:*"
它将允许来自不同域的所有请求。
对于节点 Js
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
添加科尔多瓦白名单插件
cordova plugin add cordova-plugin-whitelist
做好准备
cordova prepare
将以下行添加到配置中.xml
<access origin="*"/>
<allow-intent href="*"/>
<allow-navigation href="http://*/*" />
对于浏览器的 CORS,请按 cmd 或终端打开镶边。
对于窗户,
C:'Program Files (x86)'Google'Chrome'Application'chrome.exe" --disable-web-security --user-agent="Android" --user-data-dir="C:/temp-chrome-eng
对于 mac-osx,
open -a Google' Chrome --args --disable-web-security --user-data-dir="/Users/thantshweaung/Documents/Project/ionic/chrome_cache"
解决!
使用您的 IP 地址而不是 localhost
。例如:
http://192._._._:8088/web/webclient/version_info
相关文章:
- AJAX简单错误.XMLHttpRequest无法加载http://localhost/mpl/getPage.php.
- jQuery 表单插件:XMLHttpRequest 无法加载 http://www...没有“访问控制允许来源”
- XMLHttpRequest无法加载http://localhost:3000/get.
- XMLHttpRequest 无法在 Ionic 登录到 odoo 服务器时加载 http://localhost:80
- 显示微调器,直到 iframe 加载 http post 响应
- XMLHttpRequest 无法加载 http No Access-Control-Allow-Origin head
- XMLHttpRequest 无法加载 http://localhost:8089/jquery.访问控制允许原点不允许
- 如何异步加载 http://debug.build.phonegap.com
- XMLHttpRequest 无法加载 http
- 返回 XMLHttpRequest 的 RequireJS + NodeJS 无法加载“http”,没有“Access-
- Angular2 嵌套组件: 错误: core_2.输入不是函数 加载 http://localhost:9080/ap
- 在加载$http-get图像之前显示加载覆盖
- XMLHttpRequest无法加载http://example.com/myapp/jsonurl/.否'访问
- AngularJS 1.5:组件获胜't加载http数据
- 如何使用javascript加载http数据
- XMLHttpRequest 无法加载 http://dictionary-thesaurus.com/wordlist
- 无法加载http://url状态:0"onbeforeunload方法出错
- 如何在Ionic框架启动时加载$http service app
- XMLHttpRequest无法加载http://ideone.com/api/1/service.wsdl.Acces
- 为js脚本加载http和https