-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Differentiate slash-ended routes (foo and foo/) #1443
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
My current workarround is to check the following before use Vue Proccess client-side : if (window.location.pathname.slice(-1) !== '/') {
window.location = window.location.pathname + '/';
} but that not allows usage of url not ended by '/' so a « strict mode » should be the true solution. |
This will be possible once the pr #1215 gets merged by passing setting |
Thx @posva ! Just because it's not the same route for crawler. http://www.test.com/bonjour (file bonjour under directory /) So for SEO, it's important when crawler pass on And you are right, some user don't do the difference, and ultimatly for a pure front-side user experience it's a better thing to not have different pages behind Vue Router actually not allows that. I wanted to force « /bonjour » to be « /bonjour/ » with EDIT : I will provided some full SEO/SSR website with Vue and NodeAtlas (based on Express) with isomorphisme and it's really important my front can be display error page from I will probably directly do a 301 for all non slash-ended route to slash-ended and let « front » part not do difference between two type of URL, maybe. |
This got merged at #1215 pathToRegexOptions: { strict: true } (it's not released yet though) |
Vue guys! You're bests! EDIT:
I will wait a little more ;) |
Re @posva As I already said here (after cloture of point): #1215 This do not resolve my point, I wonder myself it's there is an issue... If I set To resume, if I create:
and with
With usage of
But what I have is that
So it's not normal? That is the reverse of description of strict no? It's possible to re-open this issue and help to resolve that in anyway ? |
@haeresis I went a bit too fast creating the issue, it works as it should: http://jsfiddle.net/0evuj9fs/ |
Thx a lot @posva for your help. Your « simple » case work, indeed but... let me introduce this: I have just add a new entry I also set See the behavior of link, it's change in fonction of source target! Follow this cases: So when you start running, it is display:
Vue... Vue... What you can do to me T-T It is the same thing I have with hydratation, after my server response the true response. Now remove Where is something I don't understand ? :D that smells like an issue then ! |
I had the same problem. This is a workaround I found. With the @nuxtjs/sitemap module everything is ok. extendRoutes: (routesIn) => {
routesIn.forEach((r) => {
if (r.path.includes('/blog')) {
r.path = r.path.replace('/blog', '/blog/');
}
});
return routesIn;
} |
What problem does this feature solve?
The following url:
is NOT the same as the following url:
for SEO crawler and HTTP point of vue.
This is not a big deal for a SPA without SEO requirement but in an SSR app this is critical.
If I use, for example, Express.js to serve my application with the strict mode and following routes :
The pages (based on Vue renderer) HTTP served for following URL will be :
http://www.exemple.com/agency/
==> agencyhttp://www.exemple.com/agency
==> errorhttp://www.exemple.com/foo
==> errorBut, when client-side Vue will perform hydratation, the component/route will be resolved as following
http://www.exemple.com/agency/
==> agency : Goodhttp://www.exemple.com/agency
==> agency : Failhttp://www.exemple.com/foo
==> error : GoodFor
http://www.exemple.com/agency
, hydratation fail because the source code come currently from errorPage process (/agency/
is not the same page as/agency
and HTTP returned a 404 error code) but client-side Vue Router find a route/agency
for/agency/
.There is maybe a way to explain to router how the route should be match ?
What does the proposed API look like?
Allows Vue Router to work in the same way as usual but allows to corretly recognise HTTP different url for SEO/SSR mode with 'strict mode'.
The text was updated successfully, but these errors were encountered: