-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cloudflare adapter dynamic routes #8827
Comments
Unfortunately wildcards aren't a generally applicable solution, because they're greedy, and because 404 requests should be handled by the framework rather than the platform. I'm not sure there's really a solution we can implement; you might be better off coming up with a process to modify the generated To be totally honest it feels like a slightly arbitrary platform limitation. As with the limit on the number of If I were you I would file a ticket with Cloudflare directly. In the meantime I'm going to take the liberty of cc'ing @jrf0110 since he's been active in this area before! |
So I have written a short script that excludes some static generated routes for all those having the same problem: import { readFileSync, writeFile } from "fs";
const staticPaths = [
"/legal",
"/auth",
"/fonts",
// Add your own paths...
];
const excludePathWildCard = staticPaths.map(e => `${e}/*`);
function run() {
try {
const rawRouteData = readFileSync("./.svelte-kit/cloudflare/_routes.json");
const parsedRouteData = JSON.parse(rawRouteData.toString());
const filteredExcludes = parsedRouteData.exclude.filter((item) => !staticPaths.some(path => item.startsWith(path)));
const fixedRoutesJson = {
...parsedRouteData,
exclude: [
...filteredExcludes,
...excludePathWildCard
]
};
writeFile("./.svelte-kit/cloudflare/_routes.json", JSON.stringify(fixedRoutesJson), () => {
console.log("Finished fixing _routes.json");
});
} catch (e) {
console.error("Failed to fix _routes.json:", e);
}
}
run(); But be careful about the matching function, so you only make the assets static that are server side generated. |
closed via #9111 — thanks @ajgeiss0702 |
Describe the bug
In it's current state the cloudflare adapter autogenerates
excludes
-routes based on the routes from the svelte-config. The issue with that is that if the app has (dynamic)routes that are longer than 100 characters the cloudflare build won't succeed because of it's limitations.It would either be great to manually include those dynamic routes - since cloudflare accepts syntaxes like
user/[name]
- so that matching patterns won't be included by the adapter and instead only the manual dynamic route will be taken or that this dynamic route will be read from the sveltekit projects file structure.Reproduction
Create a route that has more than 100 characters and try to build with cloudflare.
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: