I'm setting up a project where I need to have a nested route "/user/:id" where the id is serves as a parameter that I can pass in.
In development mode everything (all components, static assets, etc.) loads properly. However, when I build the react project and serve it in production mode, some of the images are not being loaded and looking for the assets on some nested route off the root domain. (I don't fully understand how react grabs the files to be served, but I've attached images that might give insight into this predicament.) The error in grabbing the assets occur when I visit any site off of the "user" path eg /user/234, /user/23, etc.
Below is an
Thank you!
Turns out that all I needed to do was add <base href="/">
to the head of my index.html
file!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.