question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiled build inlines PORT environment variable

See original GitHub issue

Due to how getClientEnvironment is written, PORT environment variable is being inlined into final build instead of being kept as process.env.PORT.

This will cause Razzle to fail launching on Heroku using start:prod

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

16reactions
ericvicenticommented, Oct 23, 2018

I found a pretty simple workaround to this issue, if people are still struggling with it

  // This will extract the env during production execution.. PORT will not be inlined during build
  const getEnv = c => process.env[c];
  app.listen(getEnv('PORT'));
4reactions
JacopKanecommented, Feb 16, 2018

This is my workaround for Heroku:


// getPorts.js

// bypass webpack.DefinePlugin
const { env } = require('process')

export const port = () =>
  parseInt(
    env.RAZZLE_PORT ||
      env.PORT ||
      process.env.RAZZLE_PORT ||
      process.env.PORT ||
      3000,
    10,
  )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing environment-dependent variables in webpack
There are two basic ways to achieve this. DefinePlugin. new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.
Read more >
Environment Variables - webpack
Webpack CLI offers some built-in environment variables which you can access inside a webpack configuration. Edit this page·Print this page. « Previous.
Read more >
Env Variables - AFLplusplus
This document discusses the environment variables used by AFL++ to expose ... The compile-time tools do not accept AFL-specific command-line options.
Read more >
Environment Variables in Apache
First, there are the environment variables controlled by the underlying operating system. These are set before the server starts. They can be used...
Read more >
Configuration · Cloudflare Workers docs
Specifies how wrangler build will build your project. ... The vars key defines a table of environment variables provided to your Worker ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found