Skip to content

How to use env vars with quotes in dokku #2364

Description

@cesarvarela

HI, I'm posting this here, because the question in SO got no answers yet:

I'm having trouble getting a create-react-app based application to correctly load environment variables containing double quotes:

First the dokku config shows this:

    dokku config admin
    =====> admin config vars
    REACT_APP_API:           "https://example.com"
    dokku@DokkuVM:~$ 

and my fetch calls look like this:

fetch(`${process.env.REACT_APP_API}/api/v1/whatever`)

which webpack compiles to (and of course does not work):

fetch(("\"https://example.com\"") + '/api/v1/whatever')

A similar setup is working locally, in my .env file I have:

REACT_APP_API="http://example.com"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions