A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(instance): list a separate public API address in discovery (#3774)
Hampus810687e6a392
diff --git a/fluxer_api/src/api/Config.ts b/fluxer_api/src/api/Config.tsindex 7a81da28f..721278cbb 100644--- a/fluxer_api/src/api/Config.ts+++ b/fluxer_api/src/api/Config.ts@@ -395,6 +395,7 @@ export function buildAPIConfigFromMaster(master: MasterConfig): APIConfig {},endpoints: {apiPublic: master.endpoints.api,+ apiPublicDiscovery: master.services.api.discovery_public_endpoint || master.endpoints.api,apiClient: master.endpoints.api_client,webApp: master.endpoints.app,webAppOrigins: [...new Set([new URL(master.endpoints.app).origin, ...master.services.api.app_origin_aliases])],diff --git a/fluxer_api/src/api/config/APIConfig.ts b/fluxer_api/src/api/config/APIConfig.tsindex e2e8f943a..fbb6facd0 100644--- a/fluxer_api/src/api/config/APIConfig.ts+++ b/fluxer_api/src/api/config/APIConfig.ts@@ -152,6 +152,7 @@ export interface APIConfig {};endpoints: {apiPublic: string;+ apiPublicDiscovery: string;apiClient: string;webApp: string;webAppOrigins: Array<string>;diff --git a/fluxer_api/src/api/instance/InstanceController.ts b/fluxer_api/src/api/instance/InstanceController.tsindex 1ea180138..47d16818f 100644--- a/fluxer_api/src/api/instance/InstanceController.ts+++ b/fluxer_api/src/api/instance/InstanceController.ts@@ -80,7 +80,7 @@ function buildDiscoveryStaticInput(deliveryState: runtime.emailDeliveryState,});const apiClientEndpoint = Config.endpoints.apiClient;- const apiPublicEndpoint = Config.endpoints.apiPublic;+ const apiPublicEndpoint = Config.endpoints.apiPublicDiscovery;let gifProvider: NatsGifProvider | undefined;if (gifService !== undefined) {gifProvider = gifService;diff --git a/fluxer_docs/src/content/docs/operator/environment.mdx b/fluxer_docs/src/content/docs/operator/environment.mdxindex 4f1398494..57a8e276e 100644--- a/fluxer_docs/src/content/docs/operator/environment.mdx+++ b/fluxer_docs/src/content/docs/operator/environment.mdx@@ -148,6 +148,10 @@ The public base URL of the API. When it's empty, Fluxer uses the public origin fThe API base URL Fluxer hands to clients. When it's empty, Fluxer uses the public origin followed by `/api`. With rexctl, use `rexctl config set FLUXER_API_CLIENT_ENDPOINT`.+### `FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT`++The public API base URL Fluxer lists in instance discovery as `api_public`. When it's empty, Fluxer uses `FLUXER_API_ENDPOINT`. Webhooks, signed links and federation always use `FLUXER_API_ENDPOINT`. With rexctl, use `rexctl config set FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT`.+### `FLUXER_APP_ENDPOINT`The address of the web app, which Fluxer allows through CORS and uses in links. When it's empty, Fluxer uses the public origin. With rexctl, use `rexctl config set FLUXER_APP_ENDPOINT`.diff --git a/fluxer_rexctl/internal/instance/envvars.go b/fluxer_rexctl/internal/instance/envvars.goindex 8a3041516..f3d48b2fe 100644--- a/fluxer_rexctl/internal/instance/envvars.go+++ b/fluxer_rexctl/internal/instance/envvars.go@@ -65,6 +65,7 @@ var envVars = []envVar{{"FLUXER_APP_ORIGIN_ALIASES", "address", "More web app origins, separated by commas, for an instance that serves the web app on more than one hostname. Each must be an http or https origin. The API allows each one through CORS and accepts it for sign-in handoff. For passkeys on these origins, list them and the web app origin in FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS."},{"FLUXER_API_ENDPOINT", "address", "The public base URL of the API. When it's empty, Fluxer uses the public origin followed by /api."},{"FLUXER_API_CLIENT_ENDPOINT", "address", "The API base URL Fluxer hands to clients. When it's empty, Fluxer uses the public origin followed by /api."},+ {"FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT", "address", "The public API base URL Fluxer lists in instance discovery as `api_public`. When it's empty, Fluxer uses FLUXER_API_ENDPOINT. Webhooks, signed links and federation always use FLUXER_API_ENDPOINT."},{"FLUXER_APP_ENDPOINT", "address", "The address of the web app, which Fluxer allows through CORS and uses in links. When it's empty, Fluxer uses the public origin."},{"FLUXER_GATEWAY_ENDPOINT", "address", "The public WebSocket URL of the gateway, starting with `ws` or `wss`. When it's empty, Fluxer uses `wss` on the public host followed by /gateway, or `ws` when the public scheme is `http`."},{"FLUXER_MEDIA_ENDPOINT", "address", "The public address of the media proxy. When it's empty, Fluxer uses the public origin followed by /media."},diff --git a/fluxer_rexctl/internal/instance/shipped.json b/fluxer_rexctl/internal/instance/shipped.jsonindex e33954560..339489933 100644--- a/fluxer_rexctl/internal/instance/shipped.json+++ b/fluxer_rexctl/internal/instance/shipped.json@@ -4,6 +4,7 @@"02c25f1579248b44399519b505152e6f0b3b42f99f6888d7ccab31d75aeb0786","039e161673ae76f5b8cc5562a7e6acebc1a211ffaf65d488a993f16ca481fb94","04a85d483aeaf1425fbd2134f6914ebac513646f160300e0c968ea7d6b0f33a4",+ "05b25c72202e242812464427ea26d4467f3b74ce8f9c92d4eda611d95b25566b","0b718956b039a8d8402bd9c6102322fb273159f2834509fdf23a95459c7537b9","0e54ce3bfec7340d76214240c4bb9dc8dd9a33dc9ce57eff70d8d15f909cf7ab","1263f66b22074f380e55198a32d759ae5196bb9b44d8a62473c6f41dfb770905",@@ -200,6 +201,7 @@"888cf82dcaec5041633836caa30d2d4fc06659731093865037496c0907018355","893b3367ed49800478b7152c8f46190be2ad9196a04bab99cb53a964242daed4","8b89586104a5a1f3dd6d997ce43ff935d08298983660b6fec9f8b21739dada1a",+ "8c560190f9ee396739c063aac2f115b4e4f34dc6dbcac313e0bb42cd606d41af","8f0ae94476bbf3aabae086154b1ffa23ce77427ee445f48043e11cc96860faef","8fc464560ddfd9068035acafde0dbe4fa96aad78b43e382ccd03ab89f1369cfa","90fcefc650f64640eb0527ec287b721748635e9214902c076d2b7abf3faa624c",diff --git a/fluxer_rexctl/internal/stack/files/.env.example b/fluxer_rexctl/internal/stack/files/.env.exampleindex a8dc46552..b4f8fa7fa 100644--- a/fluxer_rexctl/internal/stack/files/.env.example+++ b/fluxer_rexctl/internal/stack/files/.env.example@@ -247,6 +247,12 @@ FLUXER_VAPID_PRIVATE_KEY=# rexctl: rexctl config set FLUXER_API_CLIENT_ENDPOINT# FLUXER_API_CLIENT_ENDPOINT=+# The public API base URL Fluxer lists in instance discovery as api_public.+# When it's empty, Fluxer uses FLUXER_API_ENDPOINT. Webhooks, signed links and+# federation always use FLUXER_API_ENDPOINT.+# rexctl: rexctl config set FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT+# FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT=+# The address of the web app, which Fluxer allows through CORS and uses in# links. When it's empty, Fluxer uses the public origin.# rexctl: rexctl config set FLUXER_APP_ENDPOINTdiff --git a/fluxer_rexctl/internal/stack/files/docker-compose.yml b/fluxer_rexctl/internal/stack/files/docker-compose.ymlindex 41cb648c2..fe206c214 100644--- a/fluxer_rexctl/internal/stack/files/docker-compose.yml+++ b/fluxer_rexctl/internal/stack/files/docker-compose.yml@@ -45,6 +45,7 @@ x-fluxer-env: &fluxer-envFLUXER_API_ENDPOINT: ${FLUXER_API_ENDPOINT:-}FLUXER_API_CLIENT_ENDPOINT: ${FLUXER_API_CLIENT_ENDPOINT:-}+ FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT: ${FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT:-}FLUXER_APP_ENDPOINT: ${FLUXER_APP_ENDPOINT:-${FLUXER_PUBLIC_ORIGIN:-${FLUXER_PUBLIC_SCHEME:-https}://${FLUXER_DOMAIN:-}}}FLUXER_GATEWAY_ENDPOINT: ${FLUXER_GATEWAY_ENDPOINT:-}FLUXER_MEDIA_ENDPOINT: ${FLUXER_MEDIA_ENDPOINT:-${FLUXER_PUBLIC_ORIGIN:-${FLUXER_PUBLIC_SCHEME:-https}://${FLUXER_DOMAIN:-}}/media}diff --git a/packages/config/src/ConfigLoader.ts b/packages/config/src/ConfigLoader.tsindex 1b9ed9a5f..c25121641 100644--- a/packages/config/src/ConfigLoader.ts+++ b/packages/config/src/ConfigLoader.ts@@ -113,6 +113,7 @@ function defaultConfig(): MasterConfig {presigned_harvest_downloads_enabled: true,unfurl_ignored_hosts: [],app_origin_aliases: [],+ discovery_public_endpoint: '',storage_change_feed: {enabled: false,stream: 'STORAGE_CHANGES',diff --git a/packages/config/src/MasterConfig.ts b/packages/config/src/MasterConfig.tsindex 5876fcc89..844c7506a 100644--- a/packages/config/src/MasterConfig.ts+++ b/packages/config/src/MasterConfig.ts@@ -122,6 +122,7 @@ export interface MasterConfig {presigned_harvest_downloads_enabled: boolean;unfurl_ignored_hosts: Array<string>;app_origin_aliases: Array<string>;+ discovery_public_endpoint: string;worker?: {mode?: 'all_lanes' | 'single_lane' | 'single_task';lane?: 'realtime' | 'unfurl' | 'lifecycle' | 'batch' | 'crosspost';diff --git a/packages/config/src/config_loader/EnvironmentOverrides.ts b/packages/config/src/config_loader/EnvironmentOverrides.tsindex eb8742646..789e79577 100644--- a/packages/config/src/config_loader/EnvironmentOverrides.ts+++ b/packages/config/src/config_loader/EnvironmentOverrides.ts@@ -111,6 +111,7 @@ const NAMED_FLUXER_ENV_OVERRIDES: Record<string, NamedEnvOverride> = {},FLUXER_API_UNFURL_IGNORED_HOSTS: {path: ['services', 'api', 'unfurl_ignored_hosts'], parse: parseCsv},FLUXER_APP_ORIGIN_ALIASES: {path: ['services', 'api', 'app_origin_aliases'], parse: parseCsv},+ FLUXER_API_DISCOVERY_PUBLIC_ENDPOINT: {path: ['services', 'api', 'discovery_public_endpoint']},FLUXER_MEDIA_PROXY_SECRET_KEY: {path: ['services', 'media_proxy', 'secret_key']},FLUXER_MEDIA_PROXY_UPLOAD_RELAY_ENDPOINT: {path: ['services', 'media_proxy', 'upload_relay', 'endpoint']},FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64: {path: ['services', 'media_proxy', 'upload_relay', 'secret_base64']},