docs.nestjs.com
docs.nestjs.com copied to clipboard
Legacy docs can't be opened directly
I'm submitting a...
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request (new chapter/page)
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Acessing any legacy docs path other than root redirects to the current stable version.
https://docs.nestjs.com/v6/ works as expected, but https://docs.nestjs.com/v6/fundamentals/testing redirects to https://docs.nestjs.com.
Expected behavior
All paths should work properly.
Minimal reproduction of the problem with instructions
- Access https://docs.nestjs.com/v6/fundamentals/testing
- It gets redirected to https://docs.nestjs.com
Would you like to create a PR for this issue?
I'm not sure how the repository works to do that though.
I can see the legacy versions are in dist/
, but nowhere else on the code.
Are they compiled one last time and added there once the major version changes?
I was able to reproduce this issue locally.
It looks like the routing is happening in app-routing.module.ts. All the routes seem to point to the docs pages, so access to the old versions would fall under the wildcard route at the bottom. The relative URL of ''
used in the redirect seems to try to load any static files at that location.
v6/
works since that's an actual relative path, and index.html
is loaded automatically. However, for https://docs.nestjs.com/v6/fundamentals/testing, it would look for the path /v6/fundamental/testing
and that doesn't exist. That URL should be handled by the v6 app, which is at /v6/index.html
.
I validated this theory by going to http://localhost:3000/v6/assets and it loads a view of the assets files.
I played with adding another route that matches the versioned URLs using UrlMatcher (tutorial on custom routes), but I'm not sure how to delegate to the old version's router without changing the URL directly to the old version (e.g. /v6/), losing the sub-path in the process.
This regex matches the versioned URLs: /^\/v\d\//
FYI, as a way to get around this, I used Wayback machine to open older snapshots from the website, along with the npm package version history to figure out when each version was released. It doesn't always work (some snapshots are broken). but here're the working versions I found:
I couldn't find a working version for v7, unfortunately, do let me know if you find other alternatives. and I hope others find this helpful :)