aurelia 跨域问题

来源:互联网 发布:sm是什么体验 知乎 编辑:程序博客网 时间:2024/06/05 23:02
XMLHttpRequest cannot load http://192.168.0.100:30755/api/values. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.101:8018' is therefore not allowed access.


aurelia 部署在

http://192.168.0.101:8018

数据来源地址

http://192.168.0.100:30755


aurelia 请求访问100:30755上面的数据就会有跨域问题也就是刚上面的错误

解决办法:

在0.100:30755上面设置

<pre class="lang-cs prettyprint prettyprinted" style="margin-top: 0px; margin-bottom: 1em; padding: 5px; border: 0px; font-size: 13px; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; color: rgb(57, 51, 24); word-wrap: normal; background-color: rgb(238, 238, 238);"><code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><span class="str" style="margin: 0px; padding: 0px; border: 0px; color: rgb(128, 0, 0);">Access-Control-Allow-Origin: *</span></code>

Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS

设置方式有多种

web.config或者代码设置也行。


0 0
原创粉丝点击