vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.58k stars 4.76k forks source link

Case insensitive routing not working/beforeEach hook not called (with wrong paths) #2200

Open sabicalija opened 4 years ago

sabicalija commented 4 years ago

Bug report

We need a hook in the vue router before a site is requested from the server, because we want to achieve case insensitive routing. From the documentation of vue router we found the beforeEach hook, which should be called before every routing request, when installed globally. We installed a simple hook function, for testing purposes, using enhanceApp.js, which logs some routing information to the console.

Steps to reproduce

We deployed a test release. When opening the first link, log messages are printed to the console from the beforeEach hook. When opening the second, however, a 404 is received and no log messages printed, thus no beforeEach gets ever executed.

  1. https://www.asterics.eu/next/customize/model/Model-Customization.html
  2. https://www.asterics.eu/next/customize/model/model-customization.html

What is expected?

The documentation of vue-router indicates that routing should be possible case insensitively. However, we would expect the server to send a 404 when a resource is not available. But we're unsure if path matching is performed case sensitive or insensitive at the server. The point is, we can't change the current server setup/configuration and we don't have access to it.

What is actually happening?

The server sends a 404 with the second link. The network tab of Chrome (Version 80.0.3987.116 (Official Build) (64-bit)) shows a 404 for the first resource (model-customization.html) but loads other resources request within model-customization.html, even though caching is disabled in Chrome. It seems that the file is still loaded somehow, together with other required resources (see 1. picture below). What is most surprising is that even the 404 page is loaded from our vuepress site with a link to the root path of our site (see 2. picture below). Note that the caching was disabled and previously cached files were deleted. This means that the app is loaded somehow, but it is not possible to hook into the vue-router for case insensitive path matching, which should be enabled by default AFAIK.

image

image

Other relevant information

Environment Info:

  System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (8) x64 Intel(R) Xeon(R) CPU E3-1505M v5 @ 2.80GHz
  Binaries:
    Node: 10.17.0 - ~/.nvm/versions/node/v10.17.0/bin/node
    Yarn: 1.22.0 - ~/.nvm/versions/node/v10.17.0/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v10.17.0/bin/npm
  Browsers:
    Chrome: 80.0.3987.116
    Firefox: 72.0.1
  npmPackages:
    @vuepress/core:  1.3.1 
    @vuepress/theme-default:  1.2.0 (1.3.1)
    vuepress: ^1.3.1 => 1.3.1 
  npmGlobalPackages:
    vuepress: Not Found
sabicalija commented 4 years ago

I just saw the router-link to the index page in the response (Chrome, Network Tab).

image image

This answers one question. I understand now why the link was displayed with the 2. link.

But still, it's not clear why it is not working even though a response is received from the server.