【问题标题】:Cross origin requests fails while using HTTP使用 HTTP 时跨源请求失败
【发布时间】:2017-09-20 19:32:54
【问题描述】:

在我的 AngularJs 应用程序中,当 Angular 进入休息界面(使用 chrome 和 IE11)时出现跨域错误

您在 chrome 控制台中看到的内容:

XMLHttpRequest cannot load localhost:9080/user/api/whoami. 
 Cross origin requests are only supported for protocol schemes: 
 http, data, chrome, chrome-extension, https, chrome-extension-resource. 


在服务端,其余接口用camel实现:

restConfiguration()
    .enableCORS(true)
    .corsHeaderProperty("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers")
    .corsHeaderProperty("Access-Control-Allow-Origin","*")
    .component("servlet")
    .bindingMode(RestBindingMode.json)
    .dataFormatProperty("prettyPrint", "true");

这个问题已经在这里问过了,但总是处理本地加载的文件。

使用本地应用程序服务器 Jboss (9080) 对于前端使用 Angular (8080) 我什至不明白为什么存在跨域请求

【问题讨论】:

标签: angularjs jboss cors cross-domain wildfly


【解决方案1】:

应用程序无法连接到名为 localhost 的地址,因此错误消息显示

仅协议方案支持跨源请求:http、...

把界面改成http://localhost...一切正常

【讨论】:

    猜你喜欢
    • 2014-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-01
    • 2013-11-19
    • 2016-09-07
    • 2014-11-19
    相关资源
    最近更新 更多