feat(server): support multiple hosts in one deployment (#12950)

close CLOUD-233



#### PR Dependency Tree


* **PR #12950** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added support for configuring multiple server hosts across backend and
frontend settings.
* Enhanced deployment and Helm chart configuration to allow specifying
multiple ingress hosts.
* Updated admin and configuration interfaces to display and manage
multiple server hosts.

* **Improvements**
* Improved URL generation, OAuth, and worker service logic to
dynamically handle requests from multiple hosts.
  * Enhanced captcha verification to support multiple allowed hostnames.
* Updated frontend logic for platform-specific server base URLs and
allowed origins, including Apple app domains.
  * Expanded test coverage for multi-host scenarios.

* **Bug Fixes**
* Corrected backend logic to consistently use dynamic base URLs and
origins based on request host context.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fengmk2
2025-06-27 17:41:37 +08:00
committed by GitHub
parent 5c45c66ce8
commit dc55518c5b
21 changed files with 214 additions and 43 deletions

View File

@@ -12,6 +12,7 @@ declare global {
externalUrl?: string;
https: boolean;
host: string;
hosts: ConfigItem<string[]>;
port: number;
path: string;
name?: string;
@@ -52,6 +53,11 @@ Default to be \`[server.protocol]://[server.host][:server.port]\` if not specifi
default: 'localhost',
env: 'AFFINE_SERVER_HOST',
},
hosts: {
desc: 'Multiple hosts the server will accept requests from.',
default: [],
shape: z.array(z.string()),
},
port: {
desc: 'Which port the server will listen on.',
default: 3010,

View File

@@ -82,7 +82,7 @@ export class ServerConfigResolver {
? 'AFFiNE Beta Cloud'
: 'AFFiNE Cloud'),
version: env.version,
baseUrl: this.url.home,
baseUrl: this.url.requestBaseUrl,
type: env.DEPLOYMENT_TYPE,
features: this.server.features,
};