-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
need solution #106
Comments
I've experienced the same issue with the AWS server. It works fine on my local WAMPP server, but after hosting it on AWS, it's not functioning properly. I suspect this might be due to a server update, but I'm not entirely sure. The .env file is being loaded as index.html instead of a .env file. Could you try changing the MIME type? If you need the server to recognize the .env files for internal purposes, you might consider adding a MIME type for .env files. Here's how you can do it: Open IIS Manager: Go to your server or site. |
Please try to change the way you fetch Because import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:http/http.dart' as http;
Future<String> fetchEnvFile(String url) async {
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
return response.body;
} else {
throw Exception('Failed to load .env file');
}
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Fetch the .env file from Server
final envContent = await fetchEnvFile('https://your-base-url/.env');
// Load the environment variables from the fetched content
await dotenv.load(fileInput: envContent);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter S3 .env Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Access environment variables using dotenv
final apiUrl = dotenv.env['API_URL'] ?? 'Default API URL';
return Scaffold(
appBar: AppBar(
title: Text('Flutter S3 .env Example'),
),
body: Center(
child: Text('API URL: $apiUrl'),
),
);
}
}
|
Hi i am working in flutter web app.need to use the env.so that i have used the flutter_dotenv package.
i created .env file and add all credentials to that.
its working on local very fine.
When i deployed the app into iis server the app is not loaded.
After removing the flutter_dotenv package it app works normally.
what is the steps or solution to fix this issue?
The text was updated successfully, but these errors were encountered: