Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:31:08+00:00 2026-06-09T06:31:08+00:00

I’m creating an app that has separate server and client code (two different git

  • 0

I’m creating an app that has separate server and client code (two different git repositories).

The HTML is there just as a UI, but it still needs to load /socket/socket.io.js in order to communicate with the server.

This is my HTML:

<html>
    <head>
        <script src="/socket/socket.io.js"></script>
        <script src="js/myStuff.js"></script>
    </head>

    <body>
    </body>
</html>

When queried with an address that starts with /c, the server will automatically replace the prefix with the client code directory. So, the website is loaded like this: localhost:8080/c/index.html, and the request for js/myStuff.js is actually /c/js/myStuff.js.

This is how it’s all implemented:

var http = require("http");
var io = require("socket.io");
var fs = require("fs");
var iniparser = require("iniparser");

var config = iniparser.parseSync('./config.ini');

clientPath = config.server.clientPath; //   ../../Bla

var handler = function(req, res)
{    
    if (req.url[1] == "c")
    {
        req.url = req.url.slice(2, req.url.length); //Cut off the "/c"
        url = __dirname + "/" + clientPath + req.url;
    }
    else
    {
        url = req.url; //Nothing.
    }

    fs.readFile (url, function(err, data)
    {
        if (err)
        {
            res.writeHead(404);
            return res.end("File not found.");
        }

        res.writeHead(200);
        res.end(data);
    });
}

var server = http.createServer(handler);
server.listen(8080);
var socket = io.listen(server);

Both myStuff.js and index.html load correctly, but there is a problem with loading /socket/socket.io.js. That is very, very strange, because I don’t even touch the address.

This error is given by Google Chrome:

GET http://localhost:8080/socket/socket.io.js 404 (Not Found)

Why is this happening and how can I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:31:10+00:00Added an answer on June 9, 2026 at 6:31 am

    It doesn’t look as if you are changing it anywhere so the default location for the Socket.io JavaScript is

    <script src="/socket.io/socket.io.js"></script>
    

    not socket/socket.io.js.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I know there's a lot of other questions out there that deal with this
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.