Internal cloudflare error after adding back _routes.json to Pages app

shortsync-8ep.pages.dev deployment ID: f8482f6a-4b1d-4fdf-b814-aaf5cedd5a23 account ID: f5a4b3ee0a20c04c4bc9b4c50fc45ce3 Error log: 11:47:31.698 > tsc && vite build 11:47:31.699
11:47:33.262 vite v3.1.4 building for production... 11:47:33.293 transforming... 11:47:34.005 ✓ 49 modules transformed. 11:47:34.065 rendering chunks... 11:47:34.096 dist/index.html 0.38 KiB 11:47:34.097 dist/assets/404.3b5f8433.js 0.13 KiB / gzip: 0.14 KiB 11:47:34.098 dist/assets/index.610a3944.css 0.30 KiB / gzip: 0.22 KiB 11:47:34.103 dist/assets/index.b64da364.js 145.73 KiB / gzip: 43.18 KiB 11:47:34.140 Finished 11:47:34.140 Found Functions directory at /functions. Uploading. 11:47:35.432 ✨ Compiled Worker successfully 11:47:35.500 Found _routes.json in output directory. Uploading. 11:47:35.519 Validating asset output directory 11:47:36.404 Deploying your site to Cloudflare's global network... 11:47:37.780 Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH 11:47:37.780 Error: Failed to publish assets. For support, join our Discord (https://discord.gg/cloudflaredev) or create a ticket and reference the deployment ID: 51f8c26a-5370-4d47-8356-63138020fbc0
6 Replies
chefgaben
chefgaben5mo ago
The build works immediately after I delete _routes.json but fails after adding back _routes.json (even if empty). It fails to deploy to cloudflare with no error message besides "Failed to publish assets". Bug? For context: the first time I added _routes.json it worked but it failed after adding it back Any help would be greatly appreciated 🙏
Chaika
Chaika5mo ago
You mean empty as an a literal empty file, or nothing included/excluded? You need to have at least one include rule. There's a few other limits here: https://developers.cloudflare.com/pages/functions/routing/#limits If you could share the routes.json which worked before but not now would be helpful
Routing · Cloudflare Pages docs
Functions utilize file-based routing. Your /functions directory structure determines the designated routes that your Functions will run on. You can …
chefgaben
chefgaben5mo ago
I mean nothing included/excluded, here's the one I've been using:
{
"version": 1,
"include": ["/api"]
}
{
"version": 1,
"include": ["/api"]
}
Chaika
Chaika5mo ago
you need the excluded array defined, but it can be empty, ex:
{
"version": 1,
"include": ["/api"],
"exclude": []
}
{
"version": 1,
"include": ["/api"],
"exclude": []
}
chefgaben
chefgaben5mo ago
That's it, thank you so much! I think I fooled myself, I must've had it defined before, that's my bad. As a suggestion, perhaps the error message could be more clear i.e. "Invalid _routes.json file"? The documentation does not mention it is required either
Chaika
Chaika5mo ago
yea it really should, curious that it doesn't...