Openfire 和 strope.js:Access-Control-Allow-Origin 不允许

发布于 2024-10-26 11:45:43 字数 387 浏览 2 评论 0原文

我正在尝试使用 Jabber 创建网络聊天。我已经安装了 Openfire,并且可以通过 :9090 登录管理面板,因此服务器正在运行。

现在,当使用 strope.js 基本示例时,与 strope.js 一起出现此错误:

5XMLHttpRequest 无法加载 http://jabber.xxx.dk:7070/http-bind/。 Access-Control-Allow-Origin 不允许来源 http://jabber.xxx.dk

我怎样才能允许该域?

Im trying to create a webchat using Jabber. I have installed Openfire and i can login to the admin panel at :9090 so the server is running.

Now when using strophe.js basic example, coming with strophe.js i get this error:

5XMLHttpRequest cannot load http://jabber.xxx.dk:7070/http-bind/. Origin http://jabber.xxx.dk is not allowed by Access-Control-Allow-Origin.

How can i allow the domain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

ゝ偶尔ゞ 2024-11-02 11:45:43

感谢@SamGoody 指出了这一点。从版本 3.8.0 开始,OpenFire 现在支持 1 CORS[2],这是您的用例。要启用它,请转至 OpenFire 管理控制台、服务器、服务器设置、HTTP 绑定选项卡。确保“提供对 CORS(跨源资源共享)的支持”已启用,域列表为 *(这些是默认值)。

OpenFire 管理屏幕

Thanks to @SamGoody for pointing this out. As of version 3.8.0, OpenFire now supports1 CORS[2], which is needed for your use case. To enable it, go to the OpenFire admin console, Server, Server Settings, HTTP Binding tab. Ensure that "Provides support for CORS (Cross-Origin Resource Sharing)" is Enabled, with a domain list of * (these are the defaults).

OpenFire admin screen

狠疯拽 2024-11-02 11:45:43

如果在 Openfire 中启用 CORS 并将域策略更改为接受所有后仍无法正常工作,请检查 Openfire 的 URL。您可能需要在末尾添加“/”(例如'http://dimain:7070/http-bind/')。

没有斜杠它对我不起作用。

If it doesn't work even after enabling CORS in Openfire and changing the domain policy to accept all, then check your URL for Openfire. You may need to add '/' at the end (e.g. 'http://dimain:7070/http-bind/').

Without the slash it didn't work for me.

红尘作伴 2024-11-02 11:45:43

另一种选择是将 apache 服务器设置为代理端口 7070,这样您就不必处理跨域问题本身。 httpd.conf 文件中的代码如下所示:

ProxyRequests Off
ProxyPass /http-bind http://127.0.0.1:7070/http-bind/
ProxyPassReverse /http-bind http://127.0.0.1:7070/http-bind/

Another option is to setup your apache server to proxy port 7070 so you're not dealing with cross-domain issues per se. The code for that looks something like this inside of your httpd.conf file:

ProxyRequests Off
ProxyPass /http-bind http://127.0.0.1:7070/http-bind/
ProxyPassReverse /http-bind http://127.0.0.1:7070/http-bind/
零時差 2024-11-02 11:45:43

如果您登录管理面板,请转至“服务器设置”选项卡,然后转至“HTTP 绑定”,检查两个选项(HTTP 绑定和脚本语法)均设置为“已启用”

If you log in to the admin panel, go to the Server Settings tab, then to HTTP Bindings, check both options (HTTP Binding and Script Syntax) are set to Enabled

幽蝶幻影 2024-11-02 11:45:43

我遇到了同样的问题,并发现该端口未开放访问。
虽然浏览器说这是 CORS Access-Control-Allow-Origin 问题。
这有时是开放端口问题。请确保 http 绑定端口已打开,并且可以在您正在测试的系统上通过 tcp 进行访问。

I had faced same issue and come to know that port was not open for access.
Though it browser says it is CORS Access-Control-Allow-Origin issue.
This is sometimes open port issue. Please make sure http bind port is open and can be accessible over tcp on system your are testing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文