Hi,
I am about deploy my Easyrtc based website into production but I am facing a difficult issue :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.my-appliaction.com:8000/socket.io/?EIO=3&transport=polling&t=LqaKtG9. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).The main server of my application handles member parameters plus a forum. It is based on nodejs too. It is accessed via :
https://my-application.com.
When member connect to the easyrtc server, it is done at the specific address : easyrtc.setSocketUrl(":8000"). So, the port 8000, of the same server is used to address the Easyrtc part.
I am implementing a reverse proxy with HAProxy to terminate SSL and load balance (http mode / layer 7) .
- main_server port 443 --> proxyed to ports 3001 or 3002 (load balance)
- easyrtc_server port 8000 --> proxyed to ports 8001 or 8002 (load balance)
(Both server are deployed on two ports thanks to nodejs cluster.)All was working with no load balance (same nodejs code with number of workers limited to 1 ), but with the load balance I am having this CORS issue.
If I understand correctly the problem is that access to
https://my-application.com:8000 (Easyrtc Server) from the main server
https://my-application.com, is not allowed.
I tryed to implement on the Easyrtc server, two common solutions found via google, but it did not work :
socketServer.origins(['*:*'])
or
app.use(function (req, res, next) {
console.log(req.headers)
res.setHeader('Access-Control-Allow-Origin', "*:*')
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE')
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type')
return next()
}
)
Any suggestion will be much appreciated.
Matthieu