Skip to content

Differentiate slash-ended routes (foo and foo/) #1443

@MachinisteWeb

Description

@MachinisteWeb

What problem does this feature solve?

The following url:

http://www.exemple.com/agency/

is NOT the same as the following url:

http://www.exemple.com/agency

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 :

app.set("strict routing", true);
app.get('/agency/', agencyPage);
app.get('/*', errorPage);

The pages (based on Vue renderer) HTTP served for following URL will be :

  • http://www.exemple.com/agency/ ==> agency
  • http://www.exemple.com/agency ==> error
  • http://www.exemple.com/foo ==> error

But, when client-side Vue will perform hydratation, the component/route will be resolved as following

  • http://www.exemple.com/agency/ ==> agency : Good
  • http://www.exemple.com/agency ==> agency : Fail
  • http://www.exemple.com/foo ==> error : Good

For 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?

declare type RouteConfig = {
  ...
  strict?: boolean
  ...
}

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'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions