Tuesday, 14 March 2017

Serve static file with express on Heroku

Here are my files organisation :

http://i.imgur.com/Wdx8mKf.png

And i would like to serve the file in vr/build in a static way with express on heroku.

here is my code in app.js :

var express = require('express');
var app = express();
var path = require('path');
var port = process.env.PORT || 8080;
process.env.PWD = process.cwd();
//app.use(express.static(__dirname)); // Current directory is root
app.use(express.static(path.join(process.env.PWD, 'vr/build'))); //  "public" off of current is root


app.listen(port);
console.log('Listening on port 8080');

It works locally but doesn't seems to work on heroku i have a Cannot GET / error on heroku.

If anyone have any idea

Thanks



via user462794

No comments:

Post a Comment