mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: enable debug with localhost (#4058)
This commit is contained in:
35
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
35
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
@ -186,6 +186,7 @@ class AppFlowyCloudSharedEnv {
|
||||
AuthenticatorType get authenticatorType => _authenticatorType;
|
||||
|
||||
static Future<AppFlowyCloudSharedEnv> fromEnv() async {
|
||||
// If [Env.enableCustomCloud] is true, then use the custom cloud configuration.
|
||||
if (Env.enableCustomCloud) {
|
||||
// Use the custom cloud configuration.
|
||||
final cloudType = await getAuthenticatorType();
|
||||
@ -198,6 +199,7 @@ class AppFlowyCloudSharedEnv {
|
||||
supabaseConfig: supabaseCloudConfig,
|
||||
);
|
||||
} else {
|
||||
// Using the cloud settings from the .env file.
|
||||
final appflowyCloudConfig = AppFlowyCloudConfiguration(
|
||||
base_url: Env.afCloudUrl,
|
||||
ws_base_url: await _getAppFlowyCloudWSUrl(Env.afCloudUrl),
|
||||
@ -213,13 +215,36 @@ class AppFlowyCloudSharedEnv {
|
||||
}
|
||||
}
|
||||
|
||||
Future<AppFlowyCloudConfiguration> configurationFromUri(
|
||||
Uri baseUri,
|
||||
String baseUrl,
|
||||
) async {
|
||||
// When the host is set to 'localhost', the application will utilize the local configuration. This setup assumes that 'localhost' does not employ a reverse proxy, therefore default port settings are used.
|
||||
if (baseUri.host == "localhost") {
|
||||
return AppFlowyCloudConfiguration(
|
||||
base_url: "$baseUrl:8000",
|
||||
ws_base_url: "ws://${baseUri.host}:8000/ws",
|
||||
gotrue_url: "$baseUrl:9998",
|
||||
);
|
||||
} else {
|
||||
return AppFlowyCloudConfiguration(
|
||||
base_url: baseUrl,
|
||||
ws_base_url: await _getAppFlowyCloudWSUrl(Env.afCloudUrl),
|
||||
gotrue_url: await _getAppFlowyCloudGotrueUrl(Env.afCloudUrl),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<AppFlowyCloudConfiguration> getAppFlowyCloudConfig() async {
|
||||
final baseURL = await getAppFlowyCloudUrl();
|
||||
return AppFlowyCloudConfiguration(
|
||||
base_url: baseURL,
|
||||
ws_base_url: await _getAppFlowyCloudWSUrl(baseURL),
|
||||
gotrue_url: await _getAppFlowyCloudGotrueUrl(baseURL),
|
||||
);
|
||||
|
||||
try {
|
||||
final uri = Uri.parse(baseURL);
|
||||
return await configurationFromUri(uri, baseURL);
|
||||
} catch (e) {
|
||||
Log.error("Failed to parse AppFlowy Cloud URL: $e");
|
||||
return AppFlowyCloudConfiguration.defaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getAppFlowyCloudUrl() async {
|
||||
|
1
frontend/appflowy_flutter/lib/env/env.dart
vendored
1
frontend/appflowy_flutter/lib/env/env.dart
vendored
@ -6,6 +6,7 @@ part 'env.g.dart';
|
||||
|
||||
@Envied(path: '.env')
|
||||
abstract class Env {
|
||||
// This flag is used to decide if users can dynamically configure cloud settings. It turns true when a .env file exists containing the APPFLOWY_CLOUD_URL variable. By default, this is set to false.
|
||||
static bool get enableCustomCloud {
|
||||
return Env.authenticatorType == AuthenticatorType.appflowyCloud.value &&
|
||||
_Env.afCloudUrl.isEmpty;
|
||||
|
Reference in New Issue
Block a user