node.js - How does one serve a folder on Heroku? -
just title says, how 1 serve public folder on heroku?
heroku very inflexible, express framework must this, or heroku always spit out errors, code below, how can 1 send "/public" folder? right now, if check source of heroku page, has "index".
const express = require('express'); //for heroku! const socketio = require('socket.io'); const path = require('path'); const victor = require('victor'); const port = process.env.port || 3000; const index = path.join(__dirname + '/public/'); const server = express() .use((req, res) => res.sendfile(index) ) .listen(port, () => console.log(`listening on ${ port }`)); const io = socketio(server);
with code, heroku sending index.html file within public folder.
Comments
Post a Comment