Why the cloudflare worker is being used at every request when i have deployed a static nextjs site.

Alright, i was trying to deploy my unmodified codegen-nextjs site at cloudflare pages, so after many tries i encountered this error;

01:19:30.058 ▲ Build Completed in .vercel/output [1m]
01:19:30.181 :zap: Completed npx vercel build.
01:19:31.854
01:19:31.855 :zap: ERROR: Failed to produce a Cloudflare Pages build from the project.
01:19:31.855 :zap:
01:19:31.856 :zap: The following routes were not configured to run with the Edge Runtime:
01:19:31.856 :zap: - /api/hello
01:19:31.857 :zap:
01:19:31.857 :zap: Please make sure that all your non-static routes export the following edge runtime route segment config:
01:19:31.857 :zap: export const runtime = ‘edge’;
01:19:31.857 :zap:
01:19:31.857 :zap: You can read more about the Edge Runtime on the Next.js documentation:
01:19:31.858 :zap: Rendering: Edge and Node.js Runtimes | Next.js
01:19:31.858
01:19:31.889 Failed: Error while executing user command. Exited with error code: 1
01:19:31.899 Failed: build command exited with code: 1
01:19:33.238 Failed: error occurred while running build command

Which i solved by deleting the /api directory from the repo, and… it works!
But… after checking the site many times i noticed my cloudflare workers meter was starting to rackup pretty quick.

After seeing the log stream of functions, i can say for sure that the cloudflare pages has somehow created the workers at every routes making the site a SSR, but i cant understand why it created workers despite making static/assest files at the build time, if possible can someone guide me how to deploy a plasmic nextjs at cloudflare pages as a complete static site, here are the build logs;

|2023-12-03T20:03:37.559715Z|Success: Finished cloning repository files|
|2023-12-03T20:03:38.279515Z|Restoring from dependencies cache|
|2023-12-03T20:03:38.304512Z|Restoring from build output cache|
|2023-12-03T20:03:38.62395Z|Detected the following tools from environment: npm@9.6.7, nodejs@18.17.1|
|2023-12-03T20:03:38.624845Z|Installing project dependencies: npm clean-install --progress=false|
|2023-12-03T20:03:56.838905Z||
|2023-12-03T20:03:56.839579Z|added 471 packages, and audited 472 packages in 17s|
|2023-12-03T20:03:56.839934Z||
|2023-12-03T20:03:56.840126Z|119 packages are looking for funding|
|2023-12-03T20:03:56.840275Z| run npm fund for details|
|2023-12-03T20:03:56.867179Z||
|2023-12-03T20:03:56.867481Z|3 vulnerabilities (1 low, 2 moderate)|
|2023-12-03T20:03:56.867677Z||
|2023-12-03T20:03:56.867828Z|To address all issues, run:|
|2023-12-03T20:03:56.86801Z| npm audit fix --force|
|2023-12-03T20:03:56.86816Z||
|2023-12-03T20:03:56.868303Z|Run npm audit for details.|
|2023-12-03T20:03:56.892633Z|Executing user command: npx @cloudflare/next-on-pages@1|
|2023-12-03T20:03:58.866356Z|npm WARN exec The following package was not found and will be installed: @cloudflare/next-on-pages@1.8.0|
|2023-12-03T20:04:06.310393Z|npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.|
|2023-12-03T20:04:06.419652Z|npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead|
|2023-12-03T20:04:07.34636Z|npm WARN deprecated uuid@3.3.2: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See There’s Math.random(), and then there’s Math.random() · V8 for details.|
|2023-12-03T20:04:07.487997Z|npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (ReDos Vulnerability Regression Visibility Notice · Issue #797 · debug-js/debug · GitHub)|
|2023-12-03T20:04:10.575747Z|⚡️ @cloudflare/next-on-pages CLI v.1.8.0|
|2023-12-03T20:04:11.166891Z|⚡️ Detected Package Manager: npm (9.6.7)|
|2023-12-03T20:04:11.167225Z|⚡️ Preparing project…|
|2023-12-03T20:04:11.172432Z|⚡️ Project is ready|
|2023-12-03T20:04:11.172691Z|⚡️ Building project…|
|2023-12-03T20:04:12.533743Z|▲ npm|
|2023-12-03T20:04:12.534907Z|▲ WARN exec The following package was not found and will be installed: vercel@32.6.1|
|2023-12-03T20:04:15.560345Z|▲ npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (ReDos Vulnerability Regression Visibility Notice · Issue #797 · debug-js/debug · GitHub)|
|2023-12-03T20:04:15.704281Z|▲ npm|
|2023-12-03T20:04:15.704805Z|▲ WARN|
|2023-12-03T20:04:15.705046Z|▲ deprecated uuid@3.3.2: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See There’s Math.random(), and then there’s Math.random() · V8 for details.|
|2023-12-03T20:04:17.757326Z|▲ Vercel CLI 32.6.1|
|2023-12-03T20:04:18.199996Z|▲ Installing dependencies…|
|2023-12-03T20:04:19.816668Z|▲ up to date in 1s|
|2023-12-03T20:04:19.817526Z|▲ |
|2023-12-03T20:04:19.81779Z|▲ 119 packages are looking for funding|
|2023-12-03T20:04:19.81794Z|▲ run npm fund for details|
|2023-12-03T20:04:19.831877Z|▲ Detected Next.js version: 13.4.9|
|2023-12-03T20:04:19.841004Z|▲ Detected package-lock.json generated by npm 7+|
|2023-12-03T20:04:19.841236Z|▲ Running npm run build|
|2023-12-03T20:04:20.416392Z|▲ > tmp-cpa@0.1.0 build|
|2023-12-03T20:04:20.416776Z|▲ > next build|
|2023-12-03T20:04:21.095848Z|▲ Attention: Next.js now collects completely anonymous telemetry regarding usage.|
|2023-12-03T20:04:21.096602Z|▲ This information is used to shape Next.js’ roadmap and prioritize features.|
|2023-12-03T20:04:21.096915Z|▲ You can learn more, including how to opt-out if you’d not like to participate in this anonymous program, by visiting the following URL:|
|2023-12-03T20:04:21.097097Z|▲ https://nextjs.org/telemetry|
|2023-12-03T20:04:21.209801Z|▲ - info Skipping linting|
|2023-12-03T20:04:21.210225Z|▲ - info Checking validity of types…|
|2023-12-03T20:04:25.7782Z|▲ - info Creating an optimized production build…|
|2023-12-03T20:04:58.576875Z|▲ - info Compiled successfully|
|2023-12-03T20:04:58.580236Z|▲ - info Collecting page data…|
|2023-12-03T20:05:14.440381Z|▲ - info Generating static pages (0/11)|
|2023-12-03T20:05:14.454056Z|▲ In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.|
|2023-12-03T20:05:14.456517Z|▲ In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.|
|2023-12-03T20:05:14.469733Z|▲ In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.|
|2023-12-03T20:05:14.664355Z|▲ - info Generating static pages (2/11)|
|2023-12-03T20:05:14.693222Z|▲ - info Generating static pages (5/11)|
|2023-12-03T20:05:14.72924Z|▲ - info Generating static pages (8/11)|
|2023-12-03T20:05:14.743007Z|▲ - info Generating static pages (11/11)|
|2023-12-03T20:05:15.063868Z|▲ - info Finalizing page optimization…|
|2023-12-03T20:05:15.077084Z|▲ |
|2023-12-03T20:05:15.092358Z|▲ Route (pages) Size First Load JS|
|2023-12-03T20:05:15.092794Z|▲ ┌ ○ / 10.4 kB 228 kB|
|2023-12-03T20:05:15.093062Z|▲ ├ └ css/96c45d78be32b711.css 4.75 kB|
|2023-12-03T20:05:15.093289Z|▲ ├ /_app 0 B 143 kB|
|2023-12-03T20:05:15.093534Z|▲ ├ ○ /-2 4.95 kB 225 kB|
|2023-12-03T20:05:15.093778Z|▲ ├ └ css/ae35fa1b047e745f.css 3.27 kB|
|2023-12-03T20:05:15.094014Z|▲ ├ ○ /-3 4.62 kB 222 kB|
|2023-12-03T20:05:15.094237Z|▲ ├ └ css/8b6d5fe633efeb3d.css 4.02 kB|
|2023-12-03T20:05:15.094446Z|▲ ├ ○ /-4 7.25 kB 228 kB|
|2023-12-03T20:05:15.09464Z|▲ ├ └ css/f44798e4c5951834.css 5.71 kB|
|2023-12-03T20:05:15.094799Z|▲ ├ ○ /-5 3.56 kB 337 kB|
|2023-12-03T20:05:15.094961Z|▲ ├ └ css/41efc73490502949.css 1.54 kB|
|2023-12-03T20:05:15.095109Z|▲ ├ ○ /-6 3.87 kB 338 kB|
|2023-12-03T20:05:15.095244Z|▲ ├ └ css/d3d2dd649cd5e43a.css 1.54 kB|
|2023-12-03T20:05:15.09552Z|▲ ├ ○ /-7 1.66 kB 200 kB|
|2023-12-03T20:05:15.095767Z|▲ ├ └ css/187b9ea791a92e83.css 842 B|
|2023-12-03T20:05:15.096002Z|▲ ├ ○ /-8 3.67 kB 337 kB|
|2023-12-03T20:05:15.096151Z|▲ ├ └ css/ef9c4b2f6b542564.css 1.55 kB|
|2023-12-03T20:05:15.096376Z|▲ ├ ○ /404 182 B 143 kB|
|2023-12-03T20:05:15.096529Z|▲ └ ○ /plasmic-host 557 B 144 kB|
|2023-12-03T20:05:15.096928Z|▲ + First Load JS shared by all 144 kB|
|2023-12-03T20:05:15.097264Z|▲ ├ chunks/framework-6cbe6e332df95288.js 45.2 kB|
|2023-12-03T20:05:15.097517Z|▲ ├ chunks/main-df38220c59b07ad6.js 28.4 kB|
|2023-12-03T20:05:15.097751Z|▲ ├ chunks/pages/_app-288786869c358610.js 68.5 kB|
|2023-12-03T20:05:15.097994Z|▲ ├ chunks/webpack-6ef43a8d4a395f49.js 999 B|
|2023-12-03T20:05:15.098208Z|▲ └ css/876d048b5dab7c28.css 706 B|
|2023-12-03T20:05:15.098437Z|▲ ○ (Static) automatically rendered as static HTML (uses no initial props)|
|2023-12-03T20:05:15.326473Z|▲ Collected static files (public/, static/, .next/static): 12.405ms|
|2023-12-03T20:05:15.366468Z|▲ Build Completed in .vercel/output [57s]|
|2023-12-03T20:05:15.46663Z|⚡️ Completed npx vercel build.|
|2023-12-03T20:05:15.482757Z|⚡️ No functions detected (no functions directory generated by Vercel).|
|2023-12-03T20:05:15.539837Z||
|2023-12-03T20:05:15.540283Z|⚡️ Build Summary (@cloudflare/next-on-pages v1.8.0)|
|2023-12-03T20:05:15.540471Z|⚡️ |
|2023-12-03T20:05:15.540751Z|⚡️ Other Static Assets (76)|
|2023-12-03T20:05:15.541006Z|⚡️ ┌ /-2.html|
|2023-12-03T20:05:15.541312Z|⚡️ ├ /-3.html|
|2023-12-03T20:05:15.541565Z|⚡️ ├ /-4.html|
|2023-12-03T20:05:15.541848Z|⚡️ ├ /-5.html|
|2023-12-03T20:05:15.542003Z|⚡️ └ … 72 more|
|2023-12-03T20:05:15.542134Z||
|2023-12-03T20:05:15.542271Z|⚡️ Build log saved to ‘.vercel/output/static/_worker.js/nop-build-log.json’|
|2023-12-03T20:05:15.542411Z|⚡️ Generated ‘.vercel/output/static/_worker.js/index.js’.|
|2023-12-03T20:05:15.542557Z|⚡️ Build completed in 0.07s|
|2023-12-03T20:05:15.5873Z|Finished|
|2023-12-03T20:05:15.588036Z|Found _worker.js in output directory. Uploading.|
|2023-12-03T20:05:16.849783Z|Attaching additional modules:|
|2023-12-03T20:05:16.850609Z|- next-on-pages-dist/cache/adaptor.js (esm)|
|2023-12-03T20:05:16.850801Z|- next-on-pages-dist/cache/cache-api.js (esm)|
|2023-12-03T20:05:16.85096Z|- next-on-pages-dist/cache/kv.js (esm)|
|2023-12-03T20:05:16.909589Z|✨ Compiled Worker successfully|
|2023-12-03T20:05:17.013704Z|Found _routes.json in output directory. Uploading.|
|2023-12-03T20:05:17.029742Z|Validating asset output directory|
|2023-12-03T20:05:17.815025Z|Deploying your site to Cloudflare’s global network…|
|2023-12-03T20:05:19.406543Z|Parsed 1 valid header rule.|
|2023-12-03T20:05:20.855511Z|Uploading… (66/77)|
|2023-12-03T20:05:21.67237Z|Uploading… (70/77)|
|2023-12-03T20:05:21.813721Z|Uploading… (74/77)|
|2023-12-03T20:05:21.851997Z|Uploading… (77/77)|
|2023-12-03T20:05:21.852539Z|✨ Success! Uploaded 11 files (66 already uploaded) (1.33 sec)|
|2023-12-03T20:05:21.852883Z||
|2023-12-03T20:05:22.179939Z|✨ Upload complete!|
|2023-12-03T20:05:23.278877Z|Uploading to dependency cache|
|2023-12-03T20:05:23.288487Z|Uploading to build output cache|
|2023-12-03T20:05:23.698478Z|Success: Build output uploaded to build cache.|
|2023-12-03T20:05:29.104594Z|Success: Dependencies uploaded to build cache.|
|2023-12-03T20:05:30.123623Z|Success: Assets published!|
|2023-12-03T20:05:32.066026Z|Success: Your site was deployed!|

On a side note, here are the pagespeed insights of my cloudflare pages site;


Would also like to know what causes the performance issue in the mobile one, Thanks.

Are you using revalidate?

Honestly, i don’t know, I’m just using the nextjs codegen as-it-is through github, the only thing i did was deleting the /api directory after the first error.

And when i used exactly the same git commit at vercel or netlify, they both builds the static site with no edge functions, which was as expected.