content icon indicating copy to clipboard operation
content copied to clipboard

Accessing index.html causes "Document not found"

Open Nugine opened this issue 2 years ago • 10 comments

Environment

npx nuxi info

------------------------------
- Operating System: `Linux`
- Node Version:     `v19.7.0`
- Nuxt Version:     `3.2.3`
- Nitro Version:    `2.2.3`
- Package Manager:  `[email protected]`
- Builder:          `vite`
- User Config:      `modules`, `content`
- Runtime Modules:  `@nuxt/[email protected]`
- Build Modules:    `-`
------------------------------

miniserve: a CLI tool to serve files and dirs over HTTP

https://github.com/svenstaro/miniserve

Reproduction

npx nuxi init doc-driven-app -t doc-driven
npm install
npm run generate
miniserve .output/public --index index.html

Open http://localhost:8080/index.html Open http://localhost:8080/about/index.html

Describe the bug

2023-03-10_21-24

Additional context

The "index.html" page should redirect to the corresponding page without "index.html".

From To
http://localhost:8080/index.html http://localhost:8080/
http://localhost:8080/about/index.html http://localhost:8080/about/

Logs

No response

Nugine avatar Mar 10 '23 13:03 Nugine

Actually this is intented, you should not access the .html file but directly the / and /about pages.

atinux avatar Mar 10 '23 14:03 atinux

Actually this is intented, you should not access the .html file but directly the / and /about pages.

Anyway, it's confusing. Static hosts may not have such redirect rules. For example, GitHub Pages serves both "/" and "/index.html" pages.

I suggest adding a default redirect rule for this.

Nugine avatar Mar 10 '23 14:03 Nugine

Wondering if this should be handled directly by vue-router though? 🤔

atinux avatar Mar 10 '23 14:03 atinux

Also, what about the canonical?

atinux avatar Mar 10 '23 14:03 atinux

I know, what I mean is that your server will have duplicate pages: / and /index.html which is not the best.

Does miniserver have an option to redirect without the index.html ?

atinux avatar Mar 10 '23 14:03 atinux

I know, what I mean is that your server will have duplicate pages: / and /index.html which is not the best.

What I expect:

Path Exists Display
/ yes correct
/index.html yes redirect to "/"

Of course, I can work around by manually adding rules to my server, which is ideal.

Path Exists Display
/ yes correct
/index.html no

However, it's not easy when deploying to third-party static hosts like GitHub Pages. Current behavior:

Path Exists Display
/ yes correct
/index.html yes confusing error

Nugine avatar Mar 10 '23 15:03 Nugine

Do you have a demo on GH pages so I can check @Nugine ?

atinux avatar Mar 13 '23 18:03 atinux

https://github.com/Nugine/nuxt-content-example https://nugine.github.io/nuxt-content-example/index.html https://nugine.github.io/nuxt-content-example/about/index.html

Nugine avatar Mar 14 '23 02:03 Nugine

Any updates on this ?

It prevents me from migrating an old static site to nuxt content based project, as I cannot access /index.html anymore after added @nuxt/content into the nuxt project.

DevDengChao avatar May 31 '24 02:05 DevDengChao

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 09 '25 17:01 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Feb 08 '25 18:02 github-actions[bot]