Skip to content

Process.env variables inside index.html #1037

Closed
@CodeJjang

Description

@CodeJjang

I've read the docs thoroughly as well as issues here and haven't found such a suggestion.

How about injecting the process.env values to index.html too, just like PUBLIC_URL is being injected?

It's useful in cases you want to must embed variables (like API keys) in a script tag, e.g. when using react-google-autocomplete and you have to put the following in index.html:

 <script type="text/javascript"
            src="https://maps.googleapis.com/maps/api/js?key=%SOME_ENV_VARIABLE%&libraries=places"/>

I know I can do it by ejecting and adding parameters to webpack config, but I thought there should be a better way to perform this without ejecting.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions