0

What I want is to do certain staff on prod/qa/dev environment but by calling my lib. So the lib code, even on client side, need to know certain env variables.

Roy
  • 575
  • 2
  • 8
  • 17
  • That is [not possible](http://stackoverflow.com/questions/21315708/reading-environment-variables-with-javascript) – RickyA Dec 13 '16 at 19:39
  • 1
    So I came across [this](https://github.com/erikras/react-redux-universal-hot-example/issues/272) by which it seems I can do `new webpack.DefinePlugin({ 'process.env.x': y }) ` but then my question is, would it be passed to client side with this value? – Roy Dec 13 '16 at 19:59
  • no, those are for webpack and are only used at build time. Not when you run the app. If you want authentication/authorization in the client at run time you need to create an api where users can log in and get authorization for admin stuff. – RickyA Dec 13 '16 at 20:02
  • Well not auth, I was trying to write some debugging library (putting debug info in page and console) which will only work for non-prod env. To do that, the library needs to know info of what env it is. But I think I got my answer. So I will try to find an alternative way. Thanks. – Roy Dec 13 '16 at 22:04

0 Answers0