question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`router.mode.hash()` broken?

See original GitHub issue

Issue Description

Hello! New user here, so I may very well be getting something wrong.

I tried setting the router mode like this (in my index.html before I load the Svelte app):

<script type="module">
    import {router} from "tinro"
    router.mode.hash()
</script>

And alternatively like this (inside my .svelte app file):

<script context="module">
    import {router} from "tinro"
    router.mode.hash()
</script>

But while I can confirm that the code runs in either location… an <a href="/foo/"> still uses the History API to change the location to point to a non-existent page (/foo/). (I expected something like /myapp/#/foo/.)

The Route does work and display properly in my window, but if I reload the page the URL doesn’t work because I don’t have (and don’t want) server-side support for wrong URLs.

[Update]: There are also no errors in the console. I’m running FireFox 84.0.1.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexxNBcommented, Jan 8, 2021

I’m not sure how those changes fixed it,

Heh… There was my mistake in modules bundling - router which used Route component and router which you imported was two different things, so nothing happening when you changed mode.

Module is using in REPL. But some Svelte templates also load module ("main" or "module" field in package.json) instead Route.svelte. I recomend to avoid such templates, because it will dublicate svelte code in your bundle.

0reactions
NfNitLoopcommented, Jan 7, 2021

Huh! 0.5.5 works! I’m not sure how those changes fixed it, but I confirmed that if I switch back to 0.5.3, links do not insert the #, and if I switch back to 0.5.5, they do. 🎉 Thanks!

I’m still having the issue above with the browser back button, but I’ll open a separate issue for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hash in history mode router, breaks dynamic URL in Vue
14, Vue Router set to history mode, URL containing a hashtag "#" breaks dynamic path. const router = new VueRouter({ base: `${process.env.
Read more >
Hash in history mode router, breaks URL : r/vuejs - Reddit
Using Vue 2.6.14, Vue Router set to history mode, URL containing a hashtag "#" breaks dynamic path. const router = new VueRouter({ base…...
Read more >
Different History modes - Vue Router
The history option when creating the router instance allows us to choose among different history modes. Hash Mode #. The hash history mode...
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
This is opposed to the ancient routing were the browser address bar would display /#/lessons instead. Why this problem does not occur using...
Read more >
Fixing the 'cannot GET /URL' error on refresh with React ...
Along the way, you'll also learn how client side routers work. ... Your whole app breaks on refresh and all you get is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found