i18n:NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝 [英] i18n: NS_ERROR_DOM_BAD_URI: Access to restricted URI denied

查看:1743
本文介绍了i18n:NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的电脑上进行本地测试:

index.hml

 <!DOCTYPE html> 
< html>
< head>
<! - script src =angular.js>< / script - >
< script src =i18next.js>< / script>
< script src =app.js>< / script>
< / head>
< body>
< / body>
< / html>

app.js

  i18n.init(); 



i18next.js中的错误@ 672行

  xhr.send(payload); 




NS_ERROR_DOM_BAD_URI:禁止访问受限URI





  • 如何解决此错误? / li>

解决方案

您遇到同源问题(请参阅 http://en.wikipedia.org/wiki/Same-origin_policy )。这意味着您发送请求TO的URI与发送请求FROM的URL之间的端口,域或协议不相同。



您可以通过向您的服务器端代码添加标头来解决此问题:

Access-Control-Request-Headers

访问控制请求方法



请参阅:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS


Doing tests locally on my computer:

index.hml

<!DOCTYPE html>
<html>
    <head>
        <!--script src="angular.js"></script-->
        <script src="i18next.js"></script>
        <script src="app.js"></script>
    </head>
    <body>
    </body>
</html>

app.js

i18n.init();

Error @ line 672 in i18next.js

xhr.send(payload);

NS_ERROR_DOM_BAD_URI: Access to restricted URI denied

  • How do I solve this error?
  • Optional: What does this line do?

解决方案

You are encountering a same-origin-policy issue (see http://en.wikipedia.org/wiki/Same-origin_policy). This means that either the port, domain, or protocol is not the same between the URI that you are sending a request TO and the URL that you are sending the request FROM.

You can overcome this by adding headers to your server side code:
Access-Control-Request-Headers
Access-Control-Request-Method

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

这篇关于i18n:NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆