I am using Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc1-final which internally uses Create-react-app and AspnetCore.ReactDevelopmentServer
My Dev. Environment is using IIS for hosting multiple api's say api1 as http://localhost/api1 and api2 as http://localhost/api2
Problem is if I host my React app from Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc1-final template to http://localhost/myApp - it expects the files are always served with PublicPath "/" and hence does not work.
I know Create-react-app's Prod setup uses PublicPath from PUBLIC_URL or Homepage from package.json.
Is it possible to modify create-react-app setup to use a custom publicpath in Dev. environment?
After I enject the project, I saw these lines:
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
// "public path" at which the app is served.
So, please update PUBLIC_URL in the environment file
In your package.json
add a homepage
key. This will force all the files to be build with the prefix there defined.
// package.json
{
"name": "my-project",
"homepage": "/my-path",
// ....
}
output:
/my-path/assets/my-asset.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With