Hey guys, I have some issues with env variables while I try to deploy on Cloudflare pages. I'm trying to use the experimental way of using variables.
What I did:
.dev.vars:
GOOGLE_CLIENT_ID = "some-id"
GOOGLE_CLIENT_SECRET = "some-secret"
I added experimental.env.schema to config:
astro.config.ts
import db from "@astrojs/db";
import tailwind from "@astrojs/tailwind";
import { defineConfig, envField } from "astro/config";
import cloudflare from "@astrojs/cloudflare";
import react from "@astrojs/react";
export default defineConfig({
integrations: [
db(),
tailwind({
nesting: true,
}),
react(),
],
output: "server",
adapter: cloudflare(),
experimental: {
env: {
schema: {
GOOGLE_CLIENT_ID: envField.string({
context: "server",
access: "secret",
}),
GOOGLE_CLIENT_SECRET: envField.string({
context: "server",
access: "secret",
}),
},
},
},
vite: {
optimizeDeps: {
exclude: ["astro:db"],
},
},
});
localy build works, but on cloudflare I'm getting:
Error: Failed to publish your Function. Got error: Uncaught Error: EnvInvalidVariable: The following environment variable does not match the data type and/or properties defined in `experimental.env.schema`: GOOGLE_CLIENT_ID is not of type undefined
In cloudflare I added variables inside Settings > Environment variables tab and I can't figure out why em I getting this error. I even commited .dev.vars file.
Any suggestion what should I read to resolve this?
Thank you!