Need to set the href value for <base href=""/>
tag based on build environment configuration.
Eg:
Staging should have <base href="/staging" />
Prod should have <base href="/" />
Current setup:
Build command:
"build": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts build'",
"build:staging": "REACT_APP_ENV=staging npm run build",
"build:prod": "REACT_APP_ENV=production npm run build",
.env.staging.js:
REACT_APP_BASE_HREF=/staging
index.html:
....
<base href="" + process.env.REACT_APP_API_URL />
....
This doesn't seem to work in index.html. While similar setup works for JS files
(Probably because JS files are parsed and bundled into a single file and the bundler reads the values at that point of time)
Things tried:
index.html:
<base href=process.env.REACT_APP_API_URL />
<base href="process.env.REACT_APP_API_URL" />
<base href="%process.env.REACT_APP_API_URL%" />
(similar to PUBLIC_URL variable)
Setting basename property along with Browser Router also does not solve the problem