0

I using a angulajs as frontend and node.js REST API as backend both our on different server. I want to use socket.io, but enable to get socket.io.js file on client from the node.js server i am using

<script src="http://localhost:3000/node_modules/socket.io/socket.js"></script>

to get the socket.io file.

Error: GET "localhost:3000/node_modules/socket.io/socket.js "

  • 1
    Did you take a look at [this link](http://stackoverflow.com/questions/19426882/node-js-socket-io-socket-io-js-not-found) ? – Javier92 Sep 30 '14 at 14:03

1 Answers1

0

I highly recommend taking a look at this library: https://github.com/btford/angular-socket-io

This way you can easily integrate socket.io with Angular for client side

smk1992
  • 71
  • 3
  • 1
    I saw that thing it helped me. But now I am getting an error when I try to connect the socket through io.connect("http://localhost:3000/") XMLHttpRequest cannot load http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1412172739903-3. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:1235' is therefore not allowed access. – Muhammad Mudassir Oct 01 '14 at 14:17
  • wait which are you trying to connect to... localhost:3000 or localhost:1235 ? – smk1992 Oct 04 '14 at 17:39
  • 1235(client) to 3000(server) – Muhammad Mudassir Oct 05 '14 at 09:53
  • I believe this is happening because your trying to connect to another server, one that is different from the one that servers your client. Your basically having a CORs issue. You should look into COrs in general. It is pretty important regarding security. Here are some links that might be helpful: http://stackoverflow.com/questions/24433099/how-to-disable-withcredentials-in-http-header-with-node-js-and-request-package http://en.wikipedia.org/wiki/Cross-origin_resource_sharing – smk1992 Oct 06 '14 at 05:02