I am using SocketIO to create a web chat application.
When I work locally everything is fine, but when I release it to our live domain I get the following error:
Access to XMLHttpRequest at 'https://example.com:2096/socket.io/?EIO=3&transport=polling&t=1586507948354-0' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Here is how I connect from the client to the server:
var socket = io(document.domain + ':' + supPort, {secure: true});
I have researched and I was advised to put this into the virtual host config file of the domain in Apache2:
Header always set Access-Control-Allow-Origin: "*"
However the error is still the same.
Why am I receiving this error? How can I fix it?