environment variables return undefined when i deploy

Hi. i'm trying to deploy my app locally but in the terminal where i'm logging the variables are returning undefined

 baseURL: undefined,
  baseApiURL: undefined,
  baseWebURL: undefined,
  dashboardURL: undefined,
  gaTrackingID: undefined,
  recaptchaPK: undefined

in wrangler i have the variables like this
"env": {
     "local": {
      "name": "title",
      "vars": {
        "NEXT_PUBLIC_STAGE": "prod",
        "NEXT_PUBLIC_GA_TRACKING_ID": "xxxx",
        "NEXT_PUBLIC_RECAPTCHA_PK": "xxxxx",
        "NEXT_PUBLIC_BASE_API_URL": "xxxx",
        "NEXT_PUBLIC_BASE_WEB_URL": "xxxx",
        "NEXT_PUBLIC_DASHBOARD_URL": "xxxx"
      }
    },
    "staging": {
      "name": "title",
      "route": "xxxx.xx",
      "zone_id": "xxxx",
      "vars": {
       "vars": {
        "NEXT_PUBLIC_STAGE": "prod",
        "NEXT_PUBLIC_GA_TRACKING_ID": "xxxx",
        "NEXT_PUBLIC_RECAPTCHA_PK": "xxxxx",
        "NEXT_PUBLIC_BASE_API_URL": "xxxx",
        "NEXT_PUBLIC_BASE_WEB_URL": "xxxx",
        "NEXT_PUBLIC_DASHBOARD_URL": "xxxx"
      }
     }
    },
    "production": {
      "name": "xxxx",
      "route": "xxxxx",
      "zone_id": "xxxxx",
      "vars": {
        "NEXT_PUBLIC_STAGE": "prod",
        "NEXT_PUBLIC_GA_TRACKING_ID": "xxxx",
        "NEXT_PUBLIC_RECAPTCHA_PK": "xxxxx",
         .....
      }
    }
}


i'm logging the envoirment variables like this
 console.log('NEXT_PUBLIC_RECAPTCHA_PK:', process.env.NEXT_PUBLIC_RECAPTCHA_PK);
console.log('BASE_API_URL:', process.env.BASE_API_URL);

can anyone help me with this. am i doing something wrong?

these are the commands in package.json & i'm executing this one -> "deploy:worker": "npm run build:worker && wrangler deploy"
"build": "next build",
"build:worker": "opennextjs-cloudflare",
"dev:worker": "wrangler dev -e development --port 8001",
"preview:worker": "npm run build:worker && npm run dev:worker",
"deploy:worker": "npm run build:worker && wrangler deploy"
image.png
Was this page helpful?