Heroku pipeline - staging env variable carried into production

后端 未结 4 1807
时光取名叫无心
时光取名叫无心 2021-01-04 01:23

I\'ve recently deployed a React/Express app to Heroku, but I\'m having an issue with environment variables that are part of the built app and the Heroku deployment pipeline

4条回答
  •  臣服心动
    2021-01-04 01:53

    You cannot rebuild the slug, the main point of pipelines is to move the same slug between apps.

    What you need to do is to fetch API_URL at runtime and not during build process. You can put all envs in one file, for example env.js

    export const API_URL = process.env.API_URL;
    export const OTHER_VAR = process.env.OTHER_VAR;
    

    And then just import what you need in other files

    import { API_URL, OTHER_VAR } from 'env.js';
    

提交回复
热议问题