fix: resolve connectivity issues for Android and Web builds

- Android: Added INTERNET permission and enabled cleartext traffic in AndroidManifest.xml.
- Web: Implemented and registered CORSMiddleware in backend to allow cross-origin requests.
- Flutter: Updated SettingsProvider to use 10.0.2.2 as default for Android Emulator for easier local testing.
This commit is contained in:
2026-03-26 13:37:34 +08:00
parent a0c5e7590d
commit 6710aa0624
4 changed files with 31 additions and 4 deletions

View File

@@ -1,8 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="Hightube"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon">
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"

View File

@@ -1,9 +1,14 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/foundation.dart';
class SettingsProvider with ChangeNotifier {
// Default server address for local development.
// Using 10.0.2.2 for Android emulator or localhost for Desktop.
String _baseUrl = "http://localhost:8080";
// Use 10.0.2.2 for Android emulator to access host's localhost
static String get _defaultUrl => (defaultTargetPlatform == TargetPlatform.android && !kIsWeb)
? "http://10.0.2.2:8080"
: "http://localhost:8080";
String _baseUrl = _defaultUrl;
Color _themeColor = Colors.blue;
String get baseUrl => _baseUrl;