I am using the Explorer Sandbox with a local supergraph, I have defined Environment Variables in my settings (I can use them directly in query operations so they are definitely setup).
When I try to get an environment variable in a preflight script it cannot find then and just returns undefined.
When testing the preflight script, you’ll need to include the environment variables on the bottom right section as well. I attached a screenshot where I have it working. The first console log was without the environment variables set. The second log was with the variable set.
As you mentioned, you already set up your environment variables in Settings, so that should be good to go. But for the “Edit your Preflight Script” modal, you do need to set them there as well, for testing purposes.