Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable not accessible in public/index.html #1438

Closed
jnachtigall opened this issue Jan 24, 2017 · 3 comments · Fixed by #1440
Closed

Environment variable not accessible in public/index.html #1438

jnachtigall opened this issue Jan 24, 2017 · 3 comments · Fixed by #1440

Comments

@jnachtigall
Copy link

My public/index.html seems to have access to PUBLIC_URL but not to any other environment variable.

$ cat .env
REACT_APP_ASSETS_URL=abc

still when referring the var REACT_APP_ASSETS_URL is not resolved in public/index.html:

npm start results in URIError: Failed to decode param '/%REACT_APP_ASSETS_URL%/main.min.js' and the html still has the var string unresolved whereas the js code can access the var with <strong>{process.env.REACT_APP_ASSETS_URL}</strong>

I think not only the PUBLIC_URL var should be accessible in the html, but all vars.

Background:
My react app is included in a page that already has some header and footer which comes with external js and css. I copied the header and footer html to the public/index.html, but like to retrieve the legacy css and js from an external server.

@gaearon
Copy link
Contributor

gaearon commented Jan 24, 2017

I agree it would be a nice feature to have. Want to send a PR?

@jnachtigall
Copy link
Author

@gaearon No time, sorry (life, kids, job - in random order).

@jihchi
Copy link
Contributor

jihchi commented Jan 24, 2017

hi @jnachtigall @gaearon,

I think it should be easy so here you are #1440 .

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants