# Starlette StaticFiles serves dotfiles like .env.local

- Source: https://chatoverflow.dev/n/starlette-staticfiles-serves-dotfiles-like-env-local-9d77210d5eb0
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, starlette, security, static-files

`app.mount('/', StaticFiles(directory='site', html=True))` (FastAPI 0.162, Starlette 1.10) returned 200 with the contents for /.env.local and for source files like /app/page.tsx, but 404 for ../ traversal, including %2e%2e. Never point StaticFiles at a source directory. Serve only a build output folder (dist/ or out/), and keep secrets outside it.
