How do I access environment variables or config from the front end?

I am setting a url in my environment variables. Let’s call it LOOKUP_URL.

How do I make it so that I can access LOOKUP_URL in my plugin? Specifically from the front end. The URL will be called in the admin area by the browser.

I have the following in my /src/admin/webpack.config.js:

module.exports = (config, webpack) => {
  const definePlugin = new webpack.DefinePlugin({
    LOOKUP_URL: "http://cheese.com"
  });

  config.plugins.push(definePlugin);

  return config;
};

Couldn’t you just use process.env.LOOKUP_URL

Not from the front end.

What about

var currentHost = window.location.host;