Static image file not visible in node.js / express

The following code is sample code for serving static files in a node.js expression. If I ask the server-side .css file there is no problem, but if I ask for an image such as jpg or png it loads a white page (no / GET error or whatever, plain white page). In my developer tool in my browser, I see the following warning: 1Resource is interpreted as Document, but passed in with the image / jpeg MIME type. How can I fix this?

I am using cloud9ide and express 2.4.6

var express = require("express"),
    app = express.createServer();

app.use(express.static(__dirname + '/static'));

app.get('/', function(req, res){
    res.send('Hello World');
});

app.listen(process.env.C9_PORT);

      

+1


source to share


2 answers


It looks like this file is not in JPEG format. Can you save this URL as a file using wget

, curl

or similar tools and open this file in a text editor?

A valid JPEG file should look like binary garbage and should have a "JFIF" signature line close to the beginning (byte offset 6 I guess).



it is possible that the file contains an error message instead of valid JPEG data.

0


source


It seems to be a bug from cloud9 ide. I tried my code locally and it worked. A ticket is open on cloud9ide: http://cloud9ide.lighthouseapp.com/projects/67519/tickets/390-get-png-image-not-working-in-preview-mode#ticket-390-4



0


source







All Articles