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.

Production mode refresh causing 404

See original GitHub issue

I have a simple router setup

const router = new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/foo',
    },
    {
      path: '/foo',
      name: 'foo',
      component: Foo,
    },
  ],
});

In dev mode is all working fine. When i run npm run build and generate static files in the dist folder and then serv it let say using npm http-server everytime I refresh from e.g. localhost:8080/foo I’m getting 404. I noticed that issue when I was trying to config gh-pages which base url is username.github.io/repo_name/.

Is there something I didn’t setup properly?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

23reactions
kazuponcommented, Feb 12, 2017

This issue is not webpack template. I guess that this issue is server setting.

See the vie-router docs https://router.vuejs.org/en/essentials/history-mode.html

2reactions
mickaelbaroncommented, Feb 23, 2018

Hi,

I had the same issue. I followed this link: https://gist.github.com/szarapka/05ba804dfd1c10ad47bf

Mickael

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue Router return 404 when revisit to the url
By refreshing the page you are making a request to the server with the current url and the server returns 404. You have...
Read more >
404 when hitting refresh in a router component - Get Help
It appears that I can only access the site via the root (/) path, and the deployed site doesn't support hot reload like...
Read more >
Vue router 404 error on refreshing site or direct link access
But there is one major problem, when someone tries to access router link directly or refresh the page - app throws 404 error....
Read more >
Vue JS Production mode refresh causing 404 error
Vue JS Production mode refresh causing 404 error ... url: https://next.router.vuejs.org/api/#history createRouter({ history: createWebHashHistory ...
Read more >
vue vite refresh results in a 404 iis
Vue JS Production mode refresh causing 404 error ; 1. url: https://next.router.vuejs.org/api/#history ; 2. ​ ; 3. createRouter({ ; 4. history: createWebHashHistory ...
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