Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get environment variables to replace #61

Open
perenstrom opened this issue Apr 10, 2019 · 1 comment
Open

Can't get environment variables to replace #61

perenstrom opened this issue Apr 10, 2019 · 1 comment

Comments

@perenstrom
Copy link

This is not an issue as much as a support question. But I couldn't find another forum.

My environment variables are not being replaced when running the following in my universal reactapp:

const envify = require('envify/custom');

// function declarations etc
  browserify()
    .transform(
      babelify.configure({
        ignore: [/(bower_components)|(node_modules)/]
      })
    )
    .transform(envify(process.env))
    .bundle()
    .on('error', handleError)
    .pipe(source('app.js'))
    .pipe(buffer())
    .pipe(gulpif(globalSettings.production, stripDebug()))
    .pipe(gulpif(globalSettings.production, uglify()))
    .pipe(gulp.dest(taskSettings.scripts.dest));

It works locally, but not in my staging environment where the server shows the correct stuff based on env, but is then being replaced by client hydration.

I've described my problem in more detail in this StackOverflow question: https://stackoverflow.com/questions/55594832/envify-not-replacing-my-environment-variables

Grateful for any help!

@perenstrom
Copy link
Author

perenstrom commented Apr 10, 2019

The devil is in the details. As I said in my question, the problem only occurred on my staging (and probably prod) server. So after a while I came across app.json, a Heroku settings file, partly responsible for sending setting which environment variables should be set.

So adding "FEATURE_EXAMPLE": { "required": false} in "env": {} in my app.json fixed the problem.

I'm still curious about why I still see the variable in my dist folder instead of it being replaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant