Adam S
09/04/2022, 7:56 PMservers/id123 it takes me to localhost:3000/servers/id123 as expected. When I hit the refresh button, it 404's.
What can I do to make refreshing work?Robert Jaros
09/04/2022, 8:00 PMconfig.devServer.historyApiFallback = true to webpack.config.d/webpack.jsRobert Jaros
09/04/2022, 8:00 PMRobert Jaros
09/04/2022, 8:04 PMmain.bundle.js is included correctly (relative link will not work because there is no /servers/main.bundle.js)Adam S
09/04/2022, 8:18 PMAdam S
09/04/2022, 8:19 PMAdam S
09/04/2022, 8:22 PMmain.bundle.js look like? At the moment it's
<script type="text/javascript" src="main.bundle.js"></script>
which matches the KVision example https://github.com/rjaros/kvision-examples/blob/cae2b0c29d8db69747667fae33b3293a2f9bd490/showcase/src/main/web/index.html#L8Robert Jaros
09/04/2022, 8:31 PMsrc="/main.bundle.js" should work fine in most casesAdam S
09/04/2022, 8:34 PMRobert Jaros
09/04/2022, 8:35 PMindex.html. It's loaded when your app is first opened. When using history api routing the URL in your browser will change but the loaded file will not change. But when you hit "reload" button the browser will ask the server to get e.g. /servers/test-server. There is no such page and the server needs to know what to do - it must return the same index.html. That's what historyApiFallback option do for webpack server. You will also need to configure your production web server for this.Adam S
09/04/2022, 8:36 PM/servers/test-server, then I refresh, the URL stays as localhost:3000/servers/test-server. And then if I click the link again it navigates to localhost:3000/servers/test-server/servers/test-serverRobert Jaros
09/04/2022, 8:38 PMRobert Jaros
09/04/2022, 8:39 PMrouting.updatePageLinks() is called after the link is rendered on the page.Robert Jaros
09/04/2022, 8:41 PMAdam S
09/04/2022, 8:41 PMAdam S
09/04/2022, 8:41 PMAdam S
09/04/2022, 8:42 PMRobert Jaros
09/04/2022, 8:43 PMRobert Jaros
09/04/2022, 8:44 PMRobert Jaros
09/04/2022, 8:48 PMRobert Jaros
09/04/2022, 8:52 PMRouting instance in your app?Robert Jaros
09/04/2022, 8:57 PMio.kvision.routing.routing instance variable initialized by KVision itself, but I prefer to use my own instance for better initialization control.Robert Jaros
09/04/2022, 9:02 PMobject Manager {
lateinit var routing: Routing
fun init() { // called from start() function
routing = Routing("/", useHash = false)
routing.routing() // extension function to define routings
routing.resolve()
}
fun updatePageLinks() { // called after state change
if (::routing.isInitialized) {
window.setTimeout({
routing.updatePageLinks()
}, 0)
}
}
}Robert Jaros
09/04/2022, 9:03 PM