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

  • Home
  • SEARCH
  • 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 8149305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:49:25+00:00 2026-06-06T14:49:25+00:00

I have a standard node.js static file server that I want to use to

  • 0

I have a standard node.js static file server that I want to use to serve normal html, js, css, and jpg files in the same directory (ie- a typical HTML5 single page app). I would expect that the node server can handle this properly. What I see is different.

The index.html file is served, but then subsequent requests are dropped (ie- they never make it to the server). In my chrome dev tools, I see things like this:

GET http://projectcoho.cloudfoundry.com/css/coho.css  http://projectcoho.cloudfoundry.com/:7
GET http://projectcoho.cloudfoundry.com/sencha-touch/sencha-touch-debug.js  http://projectcoho.cloudfoundry.com/:8
GET http://projectcoho.cloudfoundry.com/coho-debug.js  http://projectcoho.cloudfoundry.com/:8

But, these resources exist on the server and you can reach them if you enter their URL directly. And for these requests, my callback in app.js is never invoked (I can tell this because console.log is never called for these files.

Here is the app.js file:

var path = ".";
var port = process.env.VCAP_APP_PORT || 3000;;

var file = new(static.Server) (path, {
  cache: 600
});

mime.define({
   'text/css': ['css'],
   'text/javascript': ['js'],
   'image/jpeg': ['jpg', 'jpeg']
});

http.createServer(function (request, response) {

    var uri = url.parse(request.url).pathname;
    var filename = libpath.join(path, uri);

    console.log("URI: " + request.url + " , filename: " + filename);

    libpath.exists(filename, function (exists) {
        console.log("Serving " + filename);
        if (!exists) {
            console.log("Not found");
            response.writeHead(404, {
                "Content-Type": "text/plain"
            });
            response.write("404 Not Found\n");
            response.end();
            return;
        }

        if (fs.statSync(filename).isDirectory()) {
            filename += '/index.html';
        }

        var type = mime.lookup(filename);
                file.serveFile(filename, 200, {'content-type' : type}, request, response);
    });
}).listen(port);

What am I missing here?

I am using node v0.6.15

  • 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-06T14:49:27+00:00Added an answer on June 6, 2026 at 2:49 pm

    In the end, the answer was that my cache.manifest file was incorrect. The client application was looking for resources in a cache, but the didn’t exist. When I corrected the manifest, things started working.

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

Sidebar

Related Questions

I have xml files with escaped HTML code in them, and I want to
I have a standard meta tag like this: <meta name=desc content=test/> That I want
I have a little escript file that connects to a node and does some
I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php.
I have a mobile site running with jQuery Mobile. I want to have standard
I have a standard textbox and I've got jQuery on the page. I want
I have a standard active record model with an attributes that is required: class
I have a standard store schema with an InvoiceLine table that contains Products. I'd
I have a standard passwd file & a usermap file - which maps unix
I have some application settings that I'd like to add to my configuration file,

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.