{"record":{"id":"e21c68326ffd13c7","repo":"framework7io/framework7","slug":"framework7-wrong-or-not-complete-browserhistory-c","errorCode":null,"errorMessage":"Framework7: wrong or not complete browserHistory configuration, trying to guess browserHistoryRoot","messagePattern":"Framework7: wrong or not complete browserHistory configuration, trying to guess browserHistoryRoot","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/core/modules/router/router-class.js","lineNumber":903,"sourceCode":"\n    let initialUrl = router.params.url;\n    let documentUrl = location.href.split(location.origin)[1];\n\n    let historyRestored;\n    const { browserHistory, browserHistoryOnLoad, browserHistorySeparator } = router.params;\n    let { browserHistoryRoot } = router.params;\n    if (\n      (window.cordova ||\n        (window.Capacitor &&\n          (window.Capacitor.isNative ||\n            (window.Capacitor.isNativePlatform && window.Capacitor.isNativePlatform())))) &&\n      browserHistory &&\n      !browserHistorySeparator &&\n      !browserHistoryRoot &&\n      location.pathname.indexOf('index.html')\n    ) {\n      // eslint-disable-next-line\n      console.warn(\n        'Framework7: wrong or not complete browserHistory configuration, trying to guess browserHistoryRoot',\n      );\n      browserHistoryRoot = location.pathname.split('index.html')[0];\n    }\n    if (!browserHistory || !browserHistoryOnLoad) {\n      if (!initialUrl) {\n        initialUrl = documentUrl;\n      }\n      if (location.search && initialUrl.indexOf('?') < 0) {\n        initialUrl += location.search;\n      }\n      if (location.hash && initialUrl.indexOf('#') < 0) {\n        initialUrl += location.hash;\n      }\n    } else {\n      if (browserHistoryRoot && documentUrl.indexOf(browserHistoryRoot) >= 0) {\n        documentUrl = documentUrl.substring(\n          documentUrl.indexOf(browserHistoryRoot) + browserHistoryRoot.length,","sourceCodeStart":885,"sourceCodeEnd":921,"githubUrl":"https://github.com/framework7io/framework7/blob/655759126686766530a027b2f8f369c991d63d1c/src/core/modules/router/router-class.js#L885-L921","documentation":"Framework7's Router supports browserHistory mode, but only an incomplete configuration was given (browserHistory enabled without a separator or root). Since it cannot reliably derive the root from the URL, it warns and guesses browserHistoryRoot from location.pathname. This is a console.warn, not a thrown error, so routing continues with the guessed root.","triggerScenarios":"Creating a Router/App with browserHistory: true but omitting both browserHistorySeparator and browserHistoryRoot, and the current pathname does not contain 'index.html' (the indexOf('index.html') check is truthy for any pathname not containing that string, and also for paths containing it only at position 0).","commonSituations":"App served from a path other than index.html (e.g. '/app/' or clean URLs) with history mode enabled; copy-pasted init options that set browserHistory without the matching root; deploying to a subdirectory without updating the router config.","solutions":["Set browserHistoryRoot explicitly in the app/router params to the base path of the app (e.g. '/my-app/').","Or set browserHistorySeparator (e.g. '/') so the root can be derived without guessing.","If history integration is not needed, disable browserHistory (use default hash navigation).","Ensure the app is served at a URL whose root matches the configured history root."],"exampleFix":"// before\nnew Framework7({ router: { browserHistory: true } });\n// after\nnew Framework7({ router: { browserHistory: true, browserHistoryRoot: '/my-app/' } });","handlingStrategy":"validation","validationCode":"const p = new URLSearchParams(); // validate router params before app init\nif (appParams.router && appParams.router.browserHistory && !appParams.router.browserHistorySeparator && !appParams.router.browserHistoryRoot) {\n  appParams.router.browserHistoryRoot = location.pathname.split('index.html')[0];\n}","typeGuard":"function hasCompleteHistoryConfig(r) {\n  return !r.browserHistory || Boolean(r.browserHistorySeparator || r.browserHistoryRoot);\n}","tryCatchPattern":null,"preventionTips":["Always set browserHistoryRoot when serving the app from a subdirectory.","Pair browserHistory with browserHistorySeparator or browserHistoryRoot in a shared config constant.","Test router init in both root and subdirectory deployments."],"tags":["router","browser-history","configuration","framework7"],"backgroundTag":"incomplete-router-history-config","analyzedSha":"655759126686766530a027b2f8f369c991d63d1c","analyzedAt":"2026-09-02T19:48:40.711Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}