I have tried to implement like shown below, but two problems I am facing.
-
I cannot expose io Object to client that I get from npm socket.io-client library when its installed in meteor server and tried to access in client by adding a script tag shown below.
<script src="http://localhost:3000/socket.io/socket.io.js"></script>
However, I solved it by fetching the io Object from cdnjs library.
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
-
Getting CORS error when trying to connect to server socket from client.
client.js (file not in meteor) file has
var socket = io('http://localhost:3000');
server.js (file in meteor) file has
import socket_io from 'socket.io';
Meteor.startup(() => {
const server = http.createServer();
const io = socket_io(server);
});
Any leads would be appreciated, thanks!