What do you mean? I’m not sure I understand the problem statement. Please fill out the help topic template as per the forum rules. Without context of your config or how you run Caddy etc, it’s impossible to answer here.
You can use the caddy run --environ flag to have Caddy emit its current environment variables at startup.
(You can also run caddy environ but keep in mind this shows the env for the current user, so if you run Caddy as a different user or under systemd or whatever then this won’t tell you the truth).