表示不能在heroku上正确提供文件

时间:2017-04-21 19:25:39

标签: javascript express heroku server

我正在尝试试用webrtc,所以我在我的localhost(PC)上启动了一个对等服务器工作正常,但是把它放在Heroku上我得到了这个错误(而它在我的本地机器上运行得非常好)< / p>

Starting process with command `node peer-server.js` 2017-04-21T19:13:50.530426+00:00 app[web.1]: Peer server up and running on port 39711 2017-04-21T19:13:51.755765+00:00 heroku[web.1]: State changed from starting to up 2017-04-21T19:13:52.912277+00:00 heroku[router]: at=info method=GET path="/" host=peerconnecto.herokuapp.com request_id=9379c3a3-b2f7-47b1-972e-8800bd9afb4e fwd="197.210.44.53" dyno=web.1 connect=0ms service=26ms status=404 bytes=380 protocol=https 2017-04-21T19:13:52.898975+00:00 app[web.1]: attempted to server peer messenger static files via /app/public/index.html 2017-04-21T19:13:52.910539+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/public/index.html' 2017-04-21T19:13:52.910541+00:00 app[web.1]: at Error (native)

下面是我的server.js文件

var express = require('express');
var app = express();
var path = require('path');
var ExpressPeerServer = require('peer').ExpressPeerServer;

app.set('port', (process.env.PORT || 3000));

app.use(express.static('public'));

app.get('/', function(req, res) {
    const index = path.join(__dirname, 'public', 'index.html');
    res.sendFile(index);
    console.log(`attempted to server peer messenger static files via ${index}`);
});

var server = app.listen(app.get('port'), () => {
    console.log(`Peer server up and running on port ${app.get('port')}`);
});

var options = {
    debug: true
}

app.use('/peerjs', ExpressPeerServer(server, options));

我有一个包含我的静态文件的公共文件夹,在page我看到的所有内容都是 Not Found

我需要帮助

0 个答案:

没有答案