Local paths in c9 don't work - Node.js


#1

Hi everyone,

I’m using a node.js environment to setup a whole web development project. Now when I run my server and open up the webpage that c9 gives me, it loads my home page. But unfortunately none of the local links work. Everything that is loaded from a CDN (Bootstrap CSS and js files and so on) work. But if i want to implement my own js-file, it won’t be loaded even though I’m pretty sure that I set the paths correctly in my tag.

What’s more, not even Images that I put to my directory by drag&drop from my local computer work. I tried to make it as easy as possible and put the image directly to the same part as the .ejs file that invokes it and simply write - it won’t work. If I load the page, the console of chrome says: "Failed to load resource: the server responded with a status of 404 (Not Found) " - even though the picture is in the exactly same folder.

So that brings me to the conclusion that I probably don’t have a path problem but a problem that I can’t use the c9 directory in my node.js environment the same way as I can use my windows directory when I’m developing locally and have own pictures loaded from a folder and not from the internet.
Is there anything I have to take care of in node.js or express.js or c9 in general, anything I need to know about using local files and connecting them to each other?

Thanks in advance!


#2

Can you provide a little more information? In Node, you need to explicitly set routing, you can’t just put files in a directory and have them be served to the client, unless you use a static file serving middleware in your routing code. Could you post your routing code, and a screenshot of the file tree so we can try to figure this out?