title: Socket.io - Cannot load file
body: <p>I made a web chat application using Node.js, socket.io and express. It's working well.<br />
  Now I want to move my chat application into my website but i have problem with paths.<br />
  My website is based on <strong><a href="http://four.laravel.com" rel="nofollow noreferrer">Laravel framework</a></strong> and has this structure.</p>
  <pre><code>Website
      /public
          /js
              /jquery1-10.js
              /chat.js        ----&gt; client side chat file.
      /app.js                 ----&gt; node.js server side file.
      /index.php
  </code></pre>
  <p>Laravel use layouts so in <code>index.php</code> file,  <code>URL::asset('/path-to-file')</code> is working well for all files inside public directory. including stylesheets and javascript.</p>
  <p>Inside my <code>index.php</code> file I call javascripts this way:</p>
  <pre><code>&lt;script src=&quot;{{ asset('js/jquery1-10.js'); }}&quot; &gt;&lt;/script&gt; // public/js/jquery1-10.js
  &lt;script src=&quot;{{ asset('js/chat.js'); }}&quot; &gt;&lt;/script&gt;  // public/js/chat.js
  &lt;script src=&quot;{{ asset('/socket.io/socket.io.js'); }}&quot; &gt;&lt;/script&gt; // ???
  </code></pre>
  <p>both <code>jquery1-10.js</code> and <code>chat.js</code> loads well<br />
  BUT can't load socket.io file. I think socket.io creates automatically! and I have no idea where it is.<br />
  Can somebody help me with this?</p>
  <p>this is <code>app.js</code> file:</p>
  <pre><code>var http = require(&quot;http&quot;);
  var express = require(&quot;express&quot;),
  app = express(),
  server = http.createServer(app),
  io = require(&quot;socket.io&quot;).listen(server);
  server.listen(4000);
  
  app.get(&quot;/*&quot;, function( req, res ) {
      res.sendfile( __dirname + &quot;/index.php&quot; );
  });
  </code></pre>
  <p>And this is my chat.js file --&gt; client side.</p>
  <pre><code>jQuery( function($){
  var socket = io.connect(); ---&gt; error happens here. can not load socket.io.js file
  </code></pre>
  <hr />
  <h1>Solved</h1>
  <p>well, I used this line:<br />
  <code>&lt;script src=&quot;http://localhost:4000/socket.io/socket.io.js&quot; &gt;&lt;/script&gt;</code></p>
  <p>instead of this:<br />
  <code>&lt;script src=&quot;{{ asset('/socket.io/socket.io.js'); }}&quot; &gt;&lt;/script&gt;</code></p>
  <p>and it worked well.</p>