XMLHttpRequest cannot load http://XXXx.json. No 'Access-Control-Allow-Origin' header is present on t
2016-06-17 21:22
801 查看
XMLHttpRequest cannot load http://0.0.0.0:3000/6a5bec410cd2f01435bc.hot-update.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4130' is therefore not allowed access.
今天遇到这个问题 浏览器通过服务器A 服务区获得文件服务器的一个json 文件 结果报错 这个错误
有两个解决办法 1
1 是使用jsonp 去请求服务 ,
2 在控制器回传给浏览器的值 response ,addheader值
增加
headers: { "Access-Control-Allow-Origin": "*" }
不过我这个比较特殊 是像文件服务器直接请求json文件
_global_viewer.loadModel('http://prodfs1.XXXX.com.cn/rst_basic_project/manifest.json');
这个文件又是通过nginx 代理找到 在文件服务器的位置
想了半天。。查了半天 没有解决思路
最后想到直接给nginx 添加header 模拟http
nginx配置文件如下
server {
listen 80 default_server;
add_header Access-Control-Allow-Origin '*' ;
listen [::]:80 default_server;
root /root/mnt/bimatrix_fs;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name localhost;增加了
add_header Access-Control-Allow-Origin '*' ;
问题解决。。浪费了半天时间
相关文章推荐
- [深度学习]暴走的残差深度学习网络家族!加深了网络还是隐式多网络叠加?
- 使用ESP8266的AT指令调用网络数据接口
- 非银行支付机构网络支付业务管理办法对第三方支付账户的影响
- 整理时下流行的浏览器User-Agent大全
- 【51CTO学院三周年】我的网络求学之路
- .NET取代理IP Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
- 【网络编程】——linux socket demo
- 主机网络ping: unknown host baidu.com问题解决
- ios学习路线—iOS高级(网络)
- git之https或http方式设置记住用户名和密码的方法
- iOS-不用网线搭建IPv6网络测试环境
- android 开发 - 使用okhttp框架封装的开发框架
- Netty 基于事件驱动模型实现的异步IO
- nginx 代理https后,spring mvc web应用redirect https变成http
- TCP/IP 封装-分用
- android viewPager网络加载图片无限自动轮播
- TCP/IP之封装
- ASiHTTPRequest 和AFNetworking的比教
- 检测网络状态的方式
- nginx使用ssl模块配置HTTPS支持