Using the Backend Declaration in the Frontend

I found the error that is causing this. The agent is unaware of which backend canister to call. This is related to this question posted here.

Since a React application created from create-react-app requires REACT_APP_ appended on an environment variable, whenever I run dfx, the agent automatically updates to call the canister Id environment variable without the REACT_APP_ appended.

For example, whenever I run dfx deploy, the following file tied to the JS agent is automatically generated .dfx/local/canisters/backend/index.js and calls the following environment variable:

export const canisterId = process.env.BACKEND_CANISTER_ID;

One way to resolve this is to include the dot-env package in the file which requires an update to the dfx package.

Has anyone found a better solution?