Fix environment detection to use global config in ENVIRONMENT constant