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

Using SPA smart URLs instead of old style HTML anchors breaks "simple" hosting on GitHub Pages (and Apache, Nginx etc. without special rewrite rules) #1873

Open
vorburger opened this issue Sep 21, 2024 · 4 comments · May be fixed by #1879

Comments

@vorburger
Copy link
Contributor

vorburger commented Sep 21, 2024

Describe the bug

https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/ works.

https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/1 (which the former URL auto-redirects to!) is broken.

So if I simply Ctrl-R reload, or copy/paste the URL from the address bar to Share with someone in an Email or IM, it's a 404.

This is because you use a "modern" client-side URL history address API.

But a "normal" classical web-server struggles with this - unless one sets up smart rewrite rules as a work-around.

For example, this site is hosted on GitHub Pages (without custom action, just plain old style serving), which struggles with this.

Perhaps you would consider at least an option to simply use old style HTML # anchors?

So you could make https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/ "redirect" to https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist#1 instead https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/1.

@vorburger
Copy link
Contributor Author

vorburger commented Sep 21, 2024

I've just noticed that you're producing a _redirects file in dist/, but that's not a "standard" which (all) web-servers understand, of course.

@vorburger
Copy link
Contributor Author

vorburger commented Sep 21, 2024

This also affects /presenter/, e.g. https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/presenter/ is "broken" (it 404s), even though if you first open https://www.vorburger.ch/LearningMachineLearning/prez/sli.dev/dist/ and then open the presenter mode via the lower left corner icon, then it works. This seems strange, on the web.

I've just noticed that you're producing a _redirects file in dist/, but that's not a "standard" ...

According to e.g. https://gitlab.com/gitlab-org/gitlab/-/issues/118593, that _redirects appears to be a Netlify specific thing; GitHub doesn't appear to have something like that. And even if it, if you wanted to "just host a static website" anywhere else, it again still wouldn't work, without e.g. a RewriteRule from good ol' mod_rewrite e.g. in a .htaccess - but that really shouldn't be necessary, for something like this (IMHO).

@KermanX
Copy link
Member

KermanX commented Sep 21, 2024

try:

routerMode: hash

in headmatter?

@vorburger
Copy link
Contributor Author

Actually, I've just figured that this problem is specific to using GitHub's (older) Pages' "Deploy from a branch" ...

... when using GitHub Actions as documented then it works just fine!

E.g. https://www.vorburger.ch/LearningMachineLearning/4 (now) loads fine (since I've switched).

Let me contribute a small line about this for your docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants