Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #1037
Closed
Open
Issue created Nov 12, 2016 by Administrator@rootContributor

Process.env variables inside index.html

Created by: 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

Assignee
Assign to
Time tracking