Skip to content
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

Visiting /docs results /docs.html then 404 if base is set as /docs/ #852

Closed
3 tasks done
JounQin opened this issue Jun 24, 2022 · 12 comments · Fixed by #1852
Closed
3 tasks done

Visiting /docs results /docs.html then 404 if base is set as /docs/ #852

JounQin opened this issue Jun 24, 2022 · 12 comments · Fixed by #1852
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@JounQin
Copy link
Contributor

JounQin commented Jun 24, 2022

Describe the bug

image

image

Reproduction

https://github.com/JounQin/test/tree/vitepress

yarn docs:build --base /docs/ && yarn docs:serve --base /docs/

Expected behavior

http://localhost:8000/docs (Without ending slash) should work same as http://localhost:8000/docs/ (With ending slash)

System Info

System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 17.64 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/Library/Caches/fnm_multishells/3706_1656066380637/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/3706_1656066380637/bin/yarn
    npm: 8.13.1 - ~/Library/Caches/fnm_multishells/3706_1656066380637/bin/npm
  Browsers:
    Chrome: 103.0.5060.53
    Firefox: 101.0.1
    Safari: 16.0
  npmPackages:
    vitepress: ^1.0.0-alpha.4 => 1.0.0-alpha.4

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@JounQin JounQin added the bug: pending triage Maybe a bug, waiting for confirmation label Jun 24, 2022
@JounQin
Copy link
Contributor Author

JounQin commented Jun 24, 2022

if (!url.pathname.endsWith('/') && !url.pathname.endsWith('.html')) {
url.pathname += '.html'
href = url.pathname + url.search + url.hash
}

@brc-dd
Copy link
Member

brc-dd commented Jun 24, 2022

This is expected. /foo/ resolves to /foo/index.html and /foo resolves /foo.html

@JounQin
Copy link
Contributor Author

JounQin commented Jun 24, 2022

@brc-dd

I think base should be checked, /docs means base, and means /docs/index.html, it is not deep link.

@kecrily
Copy link
Contributor

kecrily commented Jun 24, 2022

When people use /docs as a base it usually means they can't or don't want to make changes to the content in /. For example, they are using GitHub Pages.

The behavior you encounter is exactly as expected.

@JounQin
Copy link
Contributor Author

JounQin commented Jun 24, 2022

When people use /docs as a base it usually means they can't or don't want to make changes to the content in /. For example, they are using GitHub Pages.

The behavior you encounter is exactly as expected.

Sorry I don't quite understand, what is the issue with GitHub Pages with docs/index.html? There can't be a /docs.html if base: '/docs/' is used.

@JounQin
Copy link
Contributor Author

JounQin commented Jun 24, 2022

@brc-dd Please help to review #853

@brc-dd
Copy link
Member

brc-dd commented Jun 26, 2022

Regarding this I've another doubt. That /docs is technically considered outside the base. Then why is our router intercepting such a link in first place? 👀

What happens when you reload that /docs.html? It should be giving an actual 404 IG, not the VP one. (in production)

@JounQin
Copy link
Contributor Author

JounQin commented Jun 26, 2022

@brc-dd It results 404 as the screen shot from VP.

@JounQin
Copy link
Contributor Author

JounQin commented Jun 26, 2022

And which ever 404 the server response, it depends on the user's server setting, /docs results 404 is unexpected.

@staghouse
Copy link

staghouse commented Aug 3, 2022

Just to add some color here, VuePress handles this the way to OP is requesting. Leaving out the trailing slash resolves the url to directory index.html which does make sense to me - the path should resolve to a usable path which is the trailing slash.

This is probably more particularly important for nested documentation pages like /docs/something/index.md. When leaving out the trailing slash it resolves to /docs/something.html which would never be a built path in this case.

@ranqiangjun
Copy link

ranqiangjun commented Dec 16, 2022

+1 to this.

And add my two cents here:

  base: '/docs/',
  cleanUrls: 'with-subfolders',

I would visit https://example.com/docs, yeah, it works. BUT the link of the site name is /docs/, click the site name, the URL is changed to https://example.com/docs/, which is unexpected to me.

@ranqiangjun
Copy link

BTW, the extra .html appended to /docs as /docs.html on the screenshot happens with cleanUrls: "off"

@brc-dd brc-dd mentioned this issue Jan 28, 2023
1 task
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants