0

there, I have a little problem with node.js and express on heroku. I have a node.js server that loads up my index.html page and other resources:

process.env.PWD = process.cwd();
var express = require("express");
var fs = require("fs-extra");
var app = express();
app.use(express.static(process.env.PWD+"/Anos"));
app.use(process.env.PWD +"/Applications", express.static(process.env.PWD + '/Anos/Applications'));

app.get(process.env.PWD+"/Anos",function(req,res) {
});
console.log("hello bitche");
var server = app.listen(process.env.PORT || 8080,function() {
    console.log("Project Alexander listening on port 8080!");
});
global.io = require("socket.io").listen(server);
var login = require("./local_modules/login.js");
var saveFiles = require("./local_modules/fileFolderSave.js");
global.io.sockets.on("connection",function(client) {
    login(client,global.io,fs,process.env.PWD);
    saveFiles(client,global.io,fs,process.env.PWD);
});

This works grand on localhost, but when I deploy it to heroku from dropbox it only loads certain things like css and js files, all of which are in sub directories. The things that aren't loaded are the icon.png files from the folders in the applications folder. Dir structure:

Anos/
  index.html
  css/
     Taskbar/
     Desktop/
     Infopane/
  js/
     Taskbar/
     Desktop/
     Infopane/
  Applications/
     App1/
        icon.png
     App2/ etc..
        icon.png
  userData/
  users/
  images/

The app here) (type

an

and click login and check the console for 404 errors. Let me know if you need anything else. Any ideas? What can i change to get rid of these errors and load everything properly? Thanks in advance!

ERRORS: image

1 Answers1

0

I have once had this problem. The way I solved it was to rename my public folder as public and set it as public like this

var path = require('path')

process.env.PWD = process.cwd();
app.use(express.static(path.join(process.env.PWD, 'public')));

I hope this helps

Jalasem
  • 101
  • 2