Publish some environment variables

#1

In the front-end/client side/browser I need to use some variables what I would like to configure with server environment variables.

Is there any known solution to publish server environment variable so that I could use it in the front-end?

0 Likes

#2

Can you explain the use case a little bit? What are the variables for?

0 Likes

#3

In front-end I have calculator script what redirects client to other service. The redirect address needs to be configurable as the site/code will be deployed to multiple countries.

I resolved the problem like this:
I started to use webpack to bundle my javascripts and in webpack configuration I added:

plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        EVENT_SERVICE: JSON.stringify(process.env.EVENT_SERVICE),
        COUNTRY: JSON.stringify(process.env.COUNTRY),
      },
    })
  ]
0 Likes

#4

Ok cool seems like you’ve got it handled :+1:

0 Likes

closed #5

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

0 Likes