Heroku pipeline 從 staging promot 到 production 的時候會把 compile 過的 file 一起 copy 過去,所以如果用到 Node + Webpack 讀取環境變數再 compile 成 js 的 file 就會吃到 staging 的環境變數而不是 production 的環境變數,這又稱為 stateful builds,可以看 https://github.com/heroku/heroku-buildpack-nodejs/issues/545 有更多的討論
解決方式可以參考 https://github.com/nholden/crawl_vote/commit/cd1b89dff4812da1270d6a5d54b594aecb1a5ca7 把一些變數放到 window裡面,這樣就會吃到正確的變數
https://devcenter.heroku.com/articles/pipelines#design-considerations
沒有留言:
張貼留言