Skip to content
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

zero config detection issue with turborepo #3051

Open
MickL opened this issue Jan 31, 2025 · 5 comments
Open

zero config detection issue with turborepo #3051

MickL opened this issue Jan 31, 2025 · 5 comments
Labels
documentation Improvements or additions to documentation preset:cloudflare

Comments

@MickL
Copy link
Contributor

MickL commented Jan 31, 2025

Environment

  • bun 1.2.1
  • nitropack 2.10.4 / nitro-nightly@3.0.0-beta-28969273.f7aa9de6

Describe the bug

When deploying to Cloudflare Pages, the preset 'node-server' is selected instead of 'cloudflare-pages'. This leads to all deployments failing. I tried with both v2 and nightly v3.

Maybe some changes have been made at Cloudflare so the detection mechanism doesnt work anymore? My last successful deployment was on 14th of December. My next deployment on 16th of December failed because of selecting preset 'node-server'.

Additional informations

My Nuxt projects are still using the 'cloudflare-pages' preset.

Workaround

Set preset manually in package.json: "build": "NITRO_PRESET='cloudflare-pages' nitro build",

@MickL MickL changed the title v2/v3: Cloudflare preset is not set anymore v2/v3: Cloudflare Pages preset is not set anymore (all builds failing) Jan 31, 2025
@pi0
Copy link
Member

pi0 commented Jan 31, 2025

Just created a new project, cloudflare_pages is detected just as well. Have you set any custom command or something perhaps?

Image Image

@MickL
Copy link
Contributor Author

MickL commented Jan 31, 2025

You are right, works in a minimal reproduction repo that I created. I figured this is an issue of Turborepo that I am using: Turborepo is actually removing all environment variables that are not on the allowlist (globalEnv array): https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#strict-mode

Could you tell me what environemnt variable is used to determine that the preset cloudflare-pages should be used? I dont find the select logic in the repo. I can then open an issue at Turborepo to not remove this variable.

Workaround: turbo run build --env-mode=loose

@pi0
Copy link
Member

pi0 commented Jan 31, 2025

CF_PAGES

you can find the logic here: https://github.com/unjs/std-env/blob/main/src/providers.ts#L72

If had time do you mind to open a PR to mention about turbo repo workaround in cloudflare pages section? 🙏

@pi0 pi0 changed the title v2/v3: Cloudflare Pages preset is not set anymore (all builds failing) zero config detection issue with turborepo Jan 31, 2025
@pi0 pi0 added documentation Improvements or additions to documentation and removed pending triage labels Jan 31, 2025
@MickL
Copy link
Contributor Author

MickL commented Jan 31, 2025

Probably ALL providers would need an info that they dont get auto detected when using Turborepo without explicitly allowing the variables or setting --env-mode=loose? The same applies to Nuxt docs.

I opened an issue: vercel/turborepo#9860

I know they already have NUXT_* and NITRO_* variables on a allowlist so they dont get cut off by default. I am sure they will also add all variables that Nitro uses for detecting the deployment environment.

@pi0
Copy link
Member

pi0 commented Jan 31, 2025

We can add banner here instead in meanwhile: https://nitro.build/deploy#zero-config-providers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation preset:cloudflare
Projects
None yet
Development

No branches or pull requests

2 participants