-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Rewriting URLs #1858
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
Comments
After thinking about it, I think it's a good idea to have something like this. Having { path: '/me', alias: '/users/posva' } Maybe something called |
Maybe |
However, that'll be a little ugly. Ideally, I want it to be something more like this:
Currently, I cannot do this using aliases unless I explicitly create every route and every alias. Having dynamic aliases to be able to connect :key to :id would be fantastic. |
Please check if this solution works for you: description: |
This would be an awesome addition and I think would solve the use-case I'm working with now. Our e-commerce app has a "catch-all" Our homepage is just a CMS-driven route for the slug
I did look briefly into using the |
Thank you for this but after some thought, I don't think this is the right way to go. So far the only problem proposed seems to be slugs. There are different solutions for that scenario like including the id as part as the param (this is mainly for SEO purposes). Another solution is using a navigation guard to ensure the slug is correct, store the association of the slug to the data somewhere and use that: router.beforeEach((to, from, next) => {
if (to.name !== 'slug') return next()
let { slug } = to.params
fetchDataFromSlug(slug)
.then(data => {
storeSlugData(slug, data)
next()
})
.catch(err => {
if (err.status === 404) next({ name: 'not-found' })
else next({ name: 'error' })
})
}) If you think this is still worth pursuing, you should go through the process of an RFC: vuejs/rfcs#122 |
What problem does this feature solve?
Much like redirect, but a programmable alias route. Such as when I'm visiting '/me', actually I'm visiting '/user/:username'.
What does the proposed API look like?
{
path: '/alias',
aliasTo: to => 'path/I/would/like/to/be/aliased/to'
}
The text was updated successfully, but these errors were encountered: