javascript - Going to the router URL directly is not working -
i'm using react-router, , working fine except when go url directly. example, if clicked on link in app goes "/quizreview?quizid=naul3dmflx" works no problem. if entered url "http://localhost:3000/quizreview?quizid=naul3dmflx" says:
cannot /quizreview?quizid=naul3dmflx
here router code:
reactdom.render(( <router history={browserhistory}> <route path="/" component={app}> <indexroute component={userquiz} onenter={loginrequired}/> <route path="/login" component={login}/> <route path="/quiz/:id" component={quiz}/> <route path="/quizreview" component={postquiz}/> <route path="/quizquestions/:quizid" component={questionform}/> <route path="/questionreview/:questionid" component={questionreview}/> <route path="/noquestions" component={noquestionsdialog}/> </route> </router> ), document.getelementbyid('app'));
am doing wrong here? followed react-router tutorial , it's working fine , believe followed same instructions problem occuring.
if using html5, visit url directly browserhistory need have historyapifallback: true
in webpack file if using webpack
what historyapifallback
does, make server returns index.html
whatever url try access , since routes configured respect index.html can access of route url directly
or else can try , alternative i.e use history={hashhistory}
react-router
, visit url
http://localhost:3000/#/quizreview?quizid=naul3dmflx
Comments
Post a Comment