Skip to content

Direct links doesn't open when for routerMode: 'history' #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmytrodanylyk opened this issue Aug 19, 2017 · 12 comments
Closed

Direct links doesn't open when for routerMode: 'history' #238

dmytrodanylyk opened this issue Aug 19, 2017 · 12 comments
Labels

Comments

@dmytrodanylyk
Copy link

When I set routerMode: 'history' and open direct link http://localhost:3000/buttons I see error page with text Cannot GET /buttons.

When I open http://localhost:3000 and click on buttons, it navigate me to http://localhost:3000/buttons and render it correctly. Any idea how to fix this?

@jsmedmar
Copy link

jsmedmar commented Sep 5, 2018

I'm also having this issue

@lessfish
Copy link

same issue

@lessfish
Copy link

it seems it has not been solved for over one year?? If so, just remove the configuration from the docs

@lessfish
Copy link

lessfish commented Mar 20, 2019

my fault, we should set the server side, see https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations

I think the author should explain it for the green hand like me

@jsmedmar
Copy link

@hanzichi, do you know how to configure for github pages?

@lessfish
Copy link

@jsmedmar I think you can only use hash mode for github pages

@judeantony
Copy link

@dmytrodanylyk @jsmedmar any idea how can I get this working while running in development mode using docsify serve where I do not have any server side configurations.

@stale
Copy link

stale bot commented Feb 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@arvindanta
Copy link

@judeantony Did u find a way to run in dev mode ?

@ASaiAnudeep
Copy link

@jsmedmar to use history router mode in github pages, create 404.html file and copy the contents of index.html.
Example - reference, demo

@mupfdev
Copy link

mupfdev commented Sep 29, 2022

Brilliant little hack, thank you. This should be pointed out in the official documentation.

@trusktr
Copy link
Member

trusktr commented Feb 1, 2023

Here is the 404.html redirect trick for GitHub Pages. But note, without providing a sitemap to Google, Google will not index those pages because it ignores pages with a 404 status by default.

https://github.com/rafgraph/spa-github-pages

If you're using a static server, there may be a rewrite rule you can set to forward all requests to a particular file. F.e. with Vercel, instead of the 404.html trick, you can forward to /index.html internally, and the browser will not receive a 404 code. For Vercel, the vercel.json might look like so:

{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants