When I deploy a project across git CLI and already connect Cloudflare Works, and it builds successfully, you can view it at https://be758b82.balanced-chef.pages.dev/, it can open, but the /blog/* page doesn’t work, I check everything is OK.
After, I tried to deploy the project through npx wrangler pages deploy dist, and it worked well on every page, you can see it at https://fe5e61f6.balanced-chef.pages.dev/
By looking at the document, I found that the deployment can be successful using wrangler CLI because it reads the bocal development environment .env configuration, while the integrated deployment using git CLI uses the environment variables configured by Cloudflare Dashboard, but why is it not obtained?
If you’re using wrangler to deploy the worker, you should configure non-secret environment variables in wrangler.toml, and for secrets use a .dev.vars file and also wrangler secret put xx before running wrangler deploy.
If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behavior, add keep_vars = true to your wrangler.toml.
I don’t use Wrangler, I just use git CLI to continue deploying, and config the environment via dashboard configuration.
I just use Wrangler to confirm the deployment problem, and I think that is because my project (import.meta.env.ENV) can’t obtain dashboard environment variables. And how can I obtain this variable, maybe using process.env.ENV?
I don’t use a wrangler.tom file, my local env is .env.* file, it can be via import.meta.env.ENV obtain variables, but I don’t find any explanation about via dashboard obtain variables both Astro or Cloudflare docs.