跨域请求被阻止:同源策略不允许读取远程资源

编程入门 行业动态 更新时间:2024-10-25 20:28:30
本文介绍了跨域请求被阻止:同源策略不允许读取远程资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站中使用 CometChat,最近我的用户在接收消息时遇到了这个问题.在 FireBug 中检查后,我意识到脚本失败一定是由于 CORS 保护(由于以下错误).

I'm using CometChat in my website and recently my users art having this problem with receiving messages. After inspection in FireBug i realized it must be because of the CORS protection (due to the following error) that the script is failing.

跨域请求被阻止:同源策略不允许读取远程资源在http://x3.chatforyoursite/subscribe/...这可以通过将资源移动到同一域或启用 CORS.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://x3.chatforyoursite/subscribe/... This can be fixed by moving the resource to the same domain or enabling CORS.

现在我想知道我应该在哪里启用 CORS,因为它是在我自己的服务器上启用的,我无法访问 CometChat 服务器.

Now I'm wondering where should I enable CORS because it is enabled on my own server and I have no access to the CometChat server.

推荐答案

x3.chatforyoursite的服务器需要输出如下header:

The server at x3.chatforyoursite needs to output the following header:

Access-Control-Allow-Origin:http://www.example

http://www.example 是您的网站地址.您应该在 chatforyoursite 上检查您的设置,看看您是否可以启用此功能 - 如果不能,他们的技术支持可能是解决此问题的最佳方法.但是,要回答您的问题,您需要远程站点允许您的站点访问 AJAX 响应客户端.

Where http://www.example is your website address. You should check your settings on chatforyoursite to see if you can enable this - if not their technical support would probably be the best way to resolve this. However to answer your question, you need the remote site to allow your site to access AJAX responses client side.

这篇关于跨域请求被阻止:同源策略不允许读取远程资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-19 15:11:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/651968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   策略   资源

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!