100 rules limit on Astro-generated site
Previously, I ran my Astro website with node under Docker.
Since the cluster is getting too expensive for me in the long run, I'm in the process of switching to Cloudflare and have tried to use the Cloudflare adapter for Astro.
Apparently the workers have an upper limit for rules (100).
A _routes.json with almost 150 exclude rules is created for the static files.
Does anyone have a good approach to solving the problem?
21 Replies
Place all static files in a single directory, then exclude that entire directory with a single rule?
I would have the same idea.
However, the _routes.json is automatically created by the Astro-Cloudflare adapter...
With the new v10 adapter, however, there is only the option of extending includes/excludes and no longer overwriting it.
I also don't think it makes much sense to write a script for this, which basically overwrites the _routes.json.
Just to check, which version of the adapter are you using?
I'm also here 👋
I would like to investigate why you get 150 exclude rules with v10 of the adapter 🤔
I recommend contacting the astro team, they change the algorithm behind routes.json quite frequently, it's possible they introduced something in v10
I'm the maintainer of the Astro Cloudflare adapter 😉
oh hi :meowlul:
I have here some folder of images. Each icon was then listed individually in _routes.json.
Theoretically, I could of course also use Cloudflare's image service, but one thing at a time.
I'll see if I can create a minimal repro tonight.
I've just messed up something in the Vite configuration. As soon as I've solved that, I can try to give you more information.
And you are using v10?
yes, 10.0.1
Ok this shouldn’t happen because we do .slice(0,99)
I’ll try to reproduce it, and have a fix asap. If you are able to give me a reproducible example using stackblitz that would make it easier for me
I can't reproduce it in a new empty project
Try this: https://stackblitz.com/edit/withastro-astro-qqhqtj?file=astro.config.mjs,dist%2F_routes.json&title=Astro%20Starter%20Kit:%20Basics 😄 - There you can see, that each icon is it's own exclude rule
StackBlitz
Astro Starter Kit: Basics - StackBlitz
Run official live example code for Astro Basics, created by Withastro on StackBlitz
and under windows the generated paths are backslashes. I don't know if thats intented behavior
Thank you for letting me know. I think I found the issue, will release a fix soon
A fix for the warning of the limit is pending review, but a preview release is available:
@astrojs/[email protected]
I'll need to debug the backslash issue deeper, as I can not see this myself and we definetly use /
inside the codeThank you :D, I'll try the preview
@astrojs/[email protected]
doesn't seem to fix it, but that might be the backslash issue@alex (he/him) is it right, that _astro files are not in the exclude?
No. I can't reproduce it though. 🤔
For me there is a
/_astro/*
inside the exclude array, everytime. Can you share the project with me?https://github.com/lindner-development/website/tree/improvements
This is the project (Branch improvements)
GitHub
GitHub - lindner-development/website at improvements
https://lindnerit.io/. Contribute to lindner-development/website development by creating an account on GitHub.
@astrojs/[email protected]
I don't have a windows machine to debug the backslash issue, but our tests also don't have that issue, so I'm not really sure what happens here@alex (he/him)
The problem with the backslashes still hasn't gone away, but it works anyway.
Regardless, I get a few errors when using SolidJS...
I've also seen some issues reported about React.
For example, I get the following error both in the Wrangler Preview and deployed on Cloudflare:
See https://improvements.lindnerit-website.pages.dev/en/legal-details
Thanks.. we haven't figured out the issue with solid & react fully..
watch the repository for updates on that