JustDev
CDCloudflare Developers
•Created by JustDev on 12/7/2023 in #pages-help
environment variable
I'm not clearly understand after reading a document.
Can I use const serverURL = context.env.SERVER_URL ?
I tried using this code
export function onRequest(context) {
if (context.env.SERVER_URL === 'development') {
return new Response('This is a local environment!');
} else {
console.log('serverURL', SERVER_URL);
return new Response(SERVER_URL);
}
}
but the result was Uncaught TypeError: Cannot read properties of undefined (reading 'env')
6 replies
CDCloudflare Developers
•Created by JustDev on 12/7/2023 in #pages-help
environment variable
Could you give me a document or example of how to call SERVER_URL ?
6 replies