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

🐛 Bug Report — Runtime APIs html_handling = 'none' in a Workers with Assets doesn't find the index.html file inside a folder #7422

Closed
lakano opened this issue Dec 3, 2024 · 4 comments

Comments

@lakano
Copy link

lakano commented Dec 3, 2024

We trying to move Pages to a « Static Assets » (Worker with Static Assets but without any Worker), because this seems that Pages will disappear at some point in the future and be replaced with this new product.

But both product doesn't have the same behaviour for routing:

Imagine this structure:
/file.html
/folder/index.html

Pages:
« domain.tld/file.html » => status 200 and return /file.html
« domain.tld/folder/ » => status 200 and return /folder/index.html

Static Assets with html_handling = 'auto-trailing-slash' :

« domain.tld/file.html » => 307 to « /file » and the 2nd request return /file.html with status 200
« domain.tld/folder/ » => 200 and return /folder/index.html

Static Assets with html_handling = 'force-trailing-slash' :

« domain.tld/file.html » => 307 to « /file/ » and the 2nd request return /file.html with status 200
« domain.tld/folder/ » => 200 and return /folder/index.html

Static Assets with html_handling = 'drop-trailing-slash' :

« domain.tld/file.html » => 307 to « /file » and the 2nd request return /file.html with status 200
« domain.tld/folder/ » => 307 to « /folder » and the 2nd request return /folder/index.html with status 200

Static Assets with html_handling = 'none' :

« domain.tld/file.html » => 200 and return /file.html
« domain.tld/folder/ » => 404

May be it's a bug of the « none » option, that on a « /folder/ » with a trailing slash should return 200 with the index.html inside if exists or 404 only if not found.

Or may be it's the behaviour really expected, but in this case, it's missing an option « standard » to act like any standard website and like Pages.

Currently, it's not possible to convert our Pages projects to Workers with Assets because of all theses 307 redirections that have an impact on SEO.

@penalosa penalosa transferred this issue from cloudflare/workerd Dec 3, 2024
@GregBrimble
Copy link
Member

Hi, thanks for the report!

I wasn't able to reproduce this bit:

Pages:
« domain.tld/file.html » => status 200 and return /file.html

In my testing, Pages would redirect /file.html to /file. This is in-keeping with the auto-trailing-slash and drop-trailing-slash options for html_handling.

The auto-trailing-slash option (default) should indeed best mimic Pages' behavior. We plan to write a more detailed migration guide covering this and other features for other users coming from Pages to Workers. Thank you for trying out Workers Assets in the meantime — we appreciate your feedback!

@GregBrimble GregBrimble closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Dec 3, 2024
@lakano
Copy link
Author

lakano commented Dec 3, 2024

Hi @GregBrimble
Oh my bad, in Pages indeed on domain.tld/file.html it's a 308 redirection (similar to Worker with Static Assets on auto-trailing-slash but not the same status code)

Can I create a feature-request in this repository? To have a new option value to have the same behaviour as a normal web server (nginx, apache...) and prevent many 307/308 redirections that are not good for SEO?

@GregBrimble
Copy link
Member

Please do! I understand the desire to reduce redirects. Generally though, for SEO, duplicate content is worse, so that's why we only serve content from a single canonical URL and redirect all others to that location.

If you can describe the behavior you want in another issue tagged as a feature request, we'll consider adding that as a config option. In this case, I'm still a bit confused — it's not often that I've seen people wanting to flatten */index.html to */ but leave /file.html as /file.html. Usually they either want to serve HTML files on "pretty URLs" or they don't. And then separately, maybe care about forcing or dropping trailing slashes. If you've got a valid use-case for your setup, please do tell us about it!

Additionally, we plan to add more features to Workers Assets which will allow you to run your Worker script in front of any assets, and there you could implement your own custom routing. Expect that to be available soon-ish.

@lakano
Copy link
Author

lakano commented Dec 3, 2024

Thank you @GregBrimble !
I've just created the feature request #7430
Have a good day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants