`process.env.IS_PULL_REQUEST` doesn't seem to be set to `true` inside Docker build process

We’re using Docker on our Elixir + Svelte/Rollup setup. This is the code I use to configure our apollo client with the relevant API URL:

const isPr = `${process.env.IS_PULL_REQUEST}` == "true"
const apiUrlOverride = `${process.env.OUR_APP_GRAPHQL_URL}` != "undefined"

const apiUrl =
  apiUrlOverride ? `${process.env.OUR_APP_GRAPHQL_URL}` :
  !production ? 'http://localhost:4000/api' :
  isPr        ? `${process.env.RENDER_EXTERNAL_URL}/api` :

We’re getting CORS errors in the Broswer console on PR preview instances saying that our apollo client is configured with https://ourapp.app/api.

I did some tests in the node repl via the shell, and the output looks fine, which is leading me to conclude that the process.env.IS_PULL_REQUEST is evaluating to 'false' when the app is being built inside Docker.


> process.env.IS_PULL_REQUEST

> const isPr = `${process.env.IS_PULL_REQUEST}` == "true"

> isPr

>   isPr  ? `${process.env.RENDER_EXTERNAL_URL}/api` : 'https://ourapp.app/api'

EDIT: I should add that without a solution for this it makes it impossible for us to do meaningful QA on PR preview instances.

Hey Ben,

Environment variables are passed in as build-args for Docker environments. You will need to set the value in your Dockerfile with ARG/ENV in order to use it in the build context.

1 Like