vue-router: Cannot get /...
Regardless of what page I attempt to go to, if I try to go there directly and not through the home page, it gives me, for example:
Cannot GET /take-action
How can I navigate to these pages directly?
My router file looks like
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'hello',
component: require('components/views/Hello')
},
{
path: '/find-help',
name: 'find-help',
component: require('components/views/Find')
},
{
path: '/take-action',
name: 'take-action',
component: require('components/views/Action')
},
{
path: '/about',
name: 'About',
component: require('components/views/About')
},
{
path: '*',
name: '404',
component: require('components/views/Hello')
}
]
})
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 16 (2 by maintainers)
Duh there is a section about it… closing.
For those wondering, this is the section: https://router.vuejs.org/en/essentials/history-mode.html
If anyone stumbles upon this problem, you can just add:
historyApiFallback: trueto your webpack.config fileread more: https://webpack.js.org/configuration/dev-server/#devserver-historyapifallback
The comment was made on Mar 15, 2017 so, it’s not more than a year old by any calendar. Also, I just encountered this error and came to see a solution, but saw his comment go without being reprimand so I had to say something.
Its fine if you want to take sides, but my comment wasn’t unnecessary
I can’t help you too much @kofimokome as I am not really active with vue anymore… but check out my project, it is working:
https://github.com/openrefuge/openrefuge/blob/master/src/router/index.js https://github.com/openrefuge/openrefuge/blob/master/src/main.js
Good luck and let me/us know if you’ve gotten it fixed 👍
@awitherow Can you be more civil about your ‘help’ next time?
https://router.vuejs.org/en/essentials/history-mode.html does not solve the problem I recentlyy deployed my vue js app to heroku and I have the same problem
The comment you are referring to is more than a year old, more recent comments are fine, plus the author is not active anymore - so I think this is a bit unnecessary