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

Unknown pages are just being redirected to the main index #12

Closed
cuibonobo opened this issue Aug 19, 2021 · 3 comments
Closed

Unknown pages are just being redirected to the main index #12

cuibonobo opened this issue Aug 19, 2021 · 3 comments
Labels

Comments

@cuibonobo
Copy link
Owner

It should show a 404 error page. In addition, my data has some 302 redirects set up, but those aren't working either. Probably related to the same problem. The error pages do show up with npm run preview though (and the redirects work also).

On a completely static site (for example, just a flat list of files on B2), there's no way to specify a server response for error pages. Svelte must be relying on JavaScript to get the right behaviors, so I probably need to stop disabling hydration on all of the pages. I'm not entirely sure this is the root of the issue though.

Having arbitrary URLs just point to the main index with no redirect will probably be terrible for SEO.

@cuibonobo
Copy link
Owner Author

This StackOverflow answer suggests that we should be able to implement redirects with JavaScript even if that's not the "correct" way to handle this situation.

@cuibonobo cuibonobo added the bug label Aug 19, 2021
@cuibonobo
Copy link
Owner Author

The site is currently hosted on Cloudflare Sites, which seems to be a 'turn-key' solution to creating a site with Workers and some backend storage. It's likely that I'll have to 'eject' the site from Sites and use Workers directly in order to address these redirection issues. Here's a tutorial on serving a static site form BackBlaze B2 with a Cloudflare Workers server to handle redirection and errors: https://roote.ca/about/tutorials/static-site/

@cuibonobo
Copy link
Owner Author

I found a description of the error page behavior Cloudflare Pages docs: https://developers.cloudflare.com/pages/platform/serving-pages

To summarize:

  • If there is a 404.html file somewhere in my hierarchy, it will display that
  • If it can't find a 404.html file, it will assume that it's rendering an SPA app (which is why it always renders the index)

Rather than upend my entire rendering scheme it would be better to just prerender a 404 page.

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

No branches or pull requests

1 participant