以下の内容はhttps://tomcky.hatenadiary.jp/entry/20180327/1522136784より取得しました。


ExpressアプリケーションをHerokuにデプロイする

前回からの続き。

www.tomcky.net

Herokuで動かすにあたって、 index.js のポート指定箇所を修正する。

const express = require('express')
const basicAuth = require('basic-auth-connect');
const app = express()

app.use(basicAuth('username', 'password'));
app.get('/', (req, res) => res.send('Hello Express!'))

app.listen((process.env.PORT || 3000), () => console.log('Example app listening on port 3000!')) // ここを修正

process.env.PORT が設定されている場合はそちらをポートとする、という記述。

Procfile の作成

web: node index

あとはGit管理下においてHeroku上にアプリケーションを作成、pushしてopen。

$ git init
$ git add .
$ git commit -m "Init."
$ heroku create my-express-app
$ git push heroku master
$ heroku open

以上。




以上の内容はhttps://tomcky.hatenadiary.jp/entry/20180327/1522136784より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14