Getting BOSH to run on converse with cross-origin resource sharing

267 Views Asked by At

I am trying to setup converse on my website with BOSH, using an Apache web server. Currently, I am getting the following error:

Access to XMLHttpRequest at 'http://localhost:7070/' (redirected from 'http://localhost/http-bind') from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This is despite the fact that I have enabled Access-Control-Allow-Origin in Apache 2.4, and the header shows up on the webpage where the client is sitting, at https://localhost/index.php. The Apache httpd.conf has, at root level:

Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Credentials true

And Apache redirects from localhost/http-bind to localhost:7070, the XMPP server's BOSH port:

RewriteEngine On
RewriteRule ^/http-bind(.*)$ http://localhost:7070$1 [L]

The XMPP server, OpenFire, has BOSH and CORS enabled.

Converse's initialize method contains this line:

bosh_service_url: 'http://localhost/http-bind',

How can I get converse on my website to use BOSH via CORS?

0

There are 0 best solutions below