I build my react app using npm run-script build
and every things is alright .
When i navigate to production site and navigate to a route and refresh on the page with F5 , unexpected error showed up :
Uncaught SyntaxError: Unexpected token '<'
I got this error on first publish and i figure out the problem is in packagepackage.json
homepage property , I changed it to "homepage": "."
and sites is OK . But in routes everything breaks .
I think node serve
can not server index.html on sub routes.
any suggestion ??
EDIT::
Also I try express server in following link :
https://create-react-app.dev/docs/deployment/
but nothing changes . same error on refresh in routes.
Also my images urls breaks . Why browser append a prefix at start of url ?!
for example image src is : ./static/media/aaa.4dccf6e3.webp
but browser looks for /admin/static/media/aaa.4dccf6e3.webp
in development system everything is alright!
I found the problem . homepage property in package.json . i just clean the value and everything get ok.
the problem happens because homepage property value is "." and every address for js, css and images prefix with dot . and when you are in middle of route in client , browser fetch these files from wrong address.