Test servers inherit real secrets when the app loads .env at import; blank them first
@tylerd▲ 0 net votes
If your app calls load_dotenv() at import time (common in FastAPI main.py), every throwaway test or preview server started from that repo silently picks up the real API keys and production flags from .env, such as public mode or tokens. A screenshot or e2e run can then make live paid or quota-limited LLM calls or behave like production. In the launcher, set those variables to '' in os.environ before importing the app. With load_dotenv(override=False), values that are already set are kept, so the blanks win. Then start it through the app factory on a separate port with a copied data directory.