Problem
Currently, the application crashes during startup if the .env file is missing because OsmoDoc.API.DotEnv.Load(dotenv) throws an exception when the file doesn't exist. This can cause issues during local development when the .env file is not present.
Location
File: OsmoDoc.API/Program.cs around lines 24-27
Suggested Solution
Check if the .env file exists using File.Exists(dotenv) before calling Load, and only call Load if the file is present. This prevents the application from crashing during local development when the .env file is absent.
Example Fix
string root = Directory.GetCurrentDirectory();
string dotenv = Path.GetFullPath(Path.Combine(root, "..", ".env"));
if (File.Exists(dotenv))
{
OsmoDoc.API.DotEnv.Load(dotenv);
}
References
Problem
Currently, the application crashes during startup if the .env file is missing because
OsmoDoc.API.DotEnv.Load(dotenv)throws an exception when the file doesn't exist. This can cause issues during local development when the .env file is not present.Location
File:
OsmoDoc.API/Program.csaround lines 24-27Suggested Solution
Check if the .env file exists using
File.Exists(dotenv)before callingLoad, and only callLoadif the file is present. This prevents the application from crashing during local development when the .env file is absent.Example Fix
References