Reputation: 31
I have a react project, I now open through webstorm no problem, but directly open the folder inside the index.html
, the main page can be out, but a click will be being given, click on the link I used reactor。
Trouble who can help me solve, thank you!
Error message:
Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'file:///Users/qinchen/Desktop/change/dist/integralpage' cannot be created in a document with origin 'null' and URL 'file:///Users/qinchen/Desktop/change/dist/index.html'. at finishTransition (file:///Users/qinchen/Desktop/change/dist/bundle.js:25897:24) at file:///Users/qinchen/Desktop/change/dist/bundle.js:13142:13 at file:///Users/qinchen/Desktop/change/dist/bundle.js:13118:9 at next (file:///Users/qinchen/Desktop/change/dist/bundle.js:25765:7) at Object.loopAsync (file:///Users/qinchen/Desktop/change/dist/bundle.js:25769:3) at confirmTransitionTo (file:///Users/qinchen/Desktop/change/dist/bundle.js:13104:17) at transitionTo (file:///Users/qinchen/Desktop/change/dist/bundle.js:13130:5) at Object.push (file:///Users/qinchen/Desktop/change/dist/bundle.js:13153:5) at Object.push (file:///Users/qinchen/Desktop/change/dist/bundle.js:13395:15) at Object.push (file:///Users/qinchen/Desktop/change/dist/bundle.js:6535:15)
Upvotes: 3
Views: 7525
Reputation: 1309
install/Use Web Serve and serve the build folder. it will work.
The easiest way to handle this would be to install serve and let it handle the rest:
npm install -g serve
serve -s build
The last command shown above will serve your static site on the port 3000. Like many of serve’s internal settings, the port can be adjusted using the -l or --listen flags:
serve -s build -l 4000
Refer - https://create-react-app.dev/docs/deployment/
Upvotes: 0
Reputation: 4921
You cannot use pushState when loading up a local file (a file:/// URL in your browser), which is for security reasons. Instead, you have two options:
Upvotes: 8