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
Hello, I’m Allie!
Place all static files in a single directory, then exclude that entire directory with a single rule?
Robin Lindner
Robin LindnerOP8mo ago
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.
Hello, I’m Allie!
Just to check, which version of the adapter are you using?
alex (he/him)
alex (he/him)8mo ago
I'm also here 👋 I would like to investigate why you get 150 exclude rules with v10 of the adapter 🤔
DaniFoldi
DaniFoldi8mo ago
I recommend contacting the astro team, they change the algorithm behind routes.json quite frequently, it's possible they introduced something in v10
alex (he/him)
alex (he/him)8mo ago
I'm the maintainer of the Astro Cloudflare adapter 😉
DaniFoldi
DaniFoldi8mo ago
oh hi :meowlul:
Robin Lindner
Robin LindnerOP8mo ago
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.
No description
alex (he/him)
alex (he/him)8mo ago
And you are using v10?
Robin Lindner
Robin LindnerOP8mo ago
yes, 10.0.1
No description
alex (he/him)
alex (he/him)8mo ago
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
Robin Lindner
Robin LindnerOP8mo ago
StackBlitz
Astro Starter Kit: Basics - StackBlitz
Run official live example code for Astro Basics, created by Withastro on StackBlitz
Robin Lindner
Robin LindnerOP8mo ago
and under windows the generated paths are backslashes. I don't know if thats intented behavior
No description
alex (he/him)
alex (he/him)8mo ago
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 code
Robin Lindner
Robin LindnerOP8mo ago
Thank you :D, I'll try the preview @astrojs/[email protected] doesn't seem to fix it, but that might be the backslash issue
Robin Lindner
Robin LindnerOP8mo ago
@alex (he/him) is it right, that _astro files are not in the exclude?
No description
alex (he/him)
alex (he/him)8mo ago
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?
Robin Lindner
Robin LindnerOP8mo ago
GitHub
GitHub - lindner-development/website at improvements
https://lindnerit.io/. Contribute to lindner-development/website development by creating an account on GitHub.
alex (he/him)
alex (he/him)8mo ago
@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
Robin Lindner
Robin LindnerOP8mo ago
@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:
{
"outcome": "exception",
"scriptName": "pages-worker--2332248-preview",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "TypeError",
"message": "Cannot set properties of undefined (setting 'noHydrate')",
"timestamp": 1712082956047
}
],
"logs": [],
"eventTimestamp": 1712082956044,
"event": {
"request": {
"url": "https://improvements.lindnerit-website.pages.dev/en/legal-details",
"method": "GET",
"headers": {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0"
},
// ...
},
"response": {
"status": 200
}
},
"id": 2
}
{
"outcome": "exception",
"scriptName": "pages-worker--2332248-preview",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "TypeError",
"message": "Cannot set properties of undefined (setting 'noHydrate')",
"timestamp": 1712082956047
}
],
"logs": [],
"eventTimestamp": 1712082956044,
"event": {
"request": {
"url": "https://improvements.lindnerit-website.pages.dev/en/legal-details",
"method": "GET",
"headers": {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0"
},
// ...
},
"response": {
"status": 200
}
},
"id": 2
}
See https://improvements.lindnerit-website.pages.dev/en/legal-details
alex (he/him)
alex (he/him)8mo ago
Thanks.. we haven't figured out the issue with solid & react fully.. watch the repository for updates on that
Want results from more Discord servers?
Add your server