Problem accessing environment variables from Cloudflare pages function

According to this tutorial I set environment variable and try to access from my page function as I show bellow.
But the variables are not used properly. I did not get the result as expected. I am Prity sure the everything else are working fine because I have already tried to input the variables manually and it works just fine.


You’re deconstructing the context object which has env on it. Therefore, you’ll want to use env directly (e.g. env.AB874) or not deconstruct (so it’ll be onRequest(context) { then keep the context.env.XYZ.)

You can find more details on JS deconstructing here: Destructuring assignment - JavaScript | MDN

Sadly i tried both of the example given by you earlier. Bot of them giving me same error. did not get the result as expected.


Here is my complete code. If you don’t mind, you can help fix it.