LoginSignup
0
0

More than 3 years have passed since last update.

Cloud Foundry Deploy時のlocalhostとportの設定

Last updated at Posted at 2020-06-26

Cloud Foundry Deployの際のlocalhostとportの設定について

今回はexpressのアプリを例にとります。
CFへのdeployでは、環境変数のVCAP_APP_HOSTとVCAP_APP_PORTを用いてエンドポイントを形成する必要があります。
その時、ローカル環境開発を考慮に入れ、2つのパラメータが存在しない場合も対応します。

server/index.js
...
const HOST = process.env.VCAP_APP_HOST || 'localhost'
const PORT = process.env.VCAP_APP_PORT || 3000
app.listen(PORT, HOST)
...

ちなみに

VCAP_APP_HOSTとVCAP_APP_PORTを確認する方法

$ cf ssh <app name>
$ env

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0