In this section, we are going to change our frontend so that it makes requests to the correct backend APIs in staging and production. At the moment, both the REST API and SignalR API have hardcoded paths set to the localhost. We are going to make use of environment variables like we did in our backend to differentiate between the different environments. Let's open our frontend project in Visual Studio Code and carry out the following steps:
- First, we are going to install a library called cross-env that will allow us to set environment variables. Let's execute the following command in the Terminal:
> npm install cross-env --save-dev
- Let's add the following scripts in package.json to execute staging and production builds:
"scripts": {
...,
"build": "react-scripts build"...