I have implemented a flutter web app and created develop and release environments. I am accessing the API Url like "${ConfigEnv.baseUrl}${MyEndPointFile.jokesEndPoint}", .
The Config File looks like below:
class ConfigEnv{
static String get fileName {
if(kReleaseMode){
return '.env.production';
}
return '.env.develop';
}
static String get baseUrl{
return dotenv.env['API_URL'] ?? '';
}
}
When I run my web app locally in develop mode or release mode then the correct base urls are picked as written in .env file but when I host the web app to custom domain then the base url is getting replaced by the domain name of my hosted web app. To simplify and debug the problem, when I replace the interpolated string (baseUrl+endPoint) by complete hardcoded API URL then it is working on deployed live website as well. Why is this happening and how to resolve this?