flutter_dotenv icon indicating copy to clipboard operation
flutter_dotenv copied to clipboard

New environment variables aren't loaded if the browser has previously visited the site

Open BurningDog opened this issue 4 years ago • 2 comments

I have a working site using a .env file. I added some new environment variables to the .env file and deployed, which resulted in a runtime error with flutter_sentry as it expected those environment variables to be present but they weren't.

However, in a new browser I had no runtime error.

After investigating I compared the contents of the deployed .env file with my local .env file and found out they did not match. This was because my browser (correctly) cached the .env file. I had to set up a new .env.1 file for a panicked quick production deploy to fix this (let's pretend for a second that this was not to a high traffic ecommerce site of a major international brand).

It should be included in the documentation in large, capital letters that the server MUST be configured to set a cache-control: none header on .env files otherwise new environment variables will not be loaded by Flutter.

Alternatively, this package should either:

  • add a random number onto the env file .env.1 when building, or:
  • add a random querystring value when making the HTTP request to the .env file.

BurningDog avatar Oct 18 '21 17:10 BurningDog

Any news on this? I'm facing this issue too

sawirricardo avatar Feb 23 '22 06:02 sawirricardo

Me too.

wackazong avatar Apr 28 '22 10:04 wackazong