我正在尝试将Strophe客户端连接到Ejabbered服务器,但是每次尝试连接到服务器时都出现404错误。
下面是错误日志:
无法加载http://localhost:5280/:对预检请求的响应未通过访问控制检查:所请求的资源上没有'Access-Control-Allow-Origin'标头。因此,不允许访问来源“ http://localhost:4400”。响应的HTTP状态代码为404。
我的Strophe连接代码:
window.addEventListener(“ load”,function(){ conn = new Strophe.Connection(“ http://localhost:5280/http-bind”); conn.connect(localStorage.getItem(“ username”)+'@localhost',localStorage.getItem(“ password”),OnConnectionStatus); },错误);
答案 0 :(得分:0)
配置您的Web服务器和代理反向以及文件托管域,应该将其安装为im.server.com
127.0.0.1 localhost
192.168.0.1 im.server.com
Apache httpd.conf:
ProxyRequests Off
<Proxy *>
AddDefaultCharset UTF-8
Options +MultiViews
Order deny,allow
Deny from all
Allow from all
</Proxy>
ProxyPass /httpbind http://localhost:5280/http-bind/
ProxyPassReverse /httpbind http://localhost:5280/http-bind/
RewriteEngine On
RewriteRule /httpbind http://localhost:5280/http-bind/
Header set Access-Control-Allow-Origin: "*"
Header set Access-Control-Max-Age "1000"
Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"