mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 08:36:22 +08:00
dc55518c5b
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 -->
32 lines
746 B
TypeScript
32 lines
746 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
|
|
import { Config, OnEvent, URLHelper } from '../../base';
|
|
import { fixUrl, OriginRules } from './utils';
|
|
|
|
@Injectable()
|
|
export class WorkerService {
|
|
allowedOrigins: OriginRules = [...this.url.allowedOrigins];
|
|
|
|
constructor(
|
|
private readonly config: Config,
|
|
private readonly url: URLHelper
|
|
) {}
|
|
|
|
@OnEvent('config.init')
|
|
onConfigInit() {
|
|
this.allowedOrigins = [
|
|
...this.config.worker.allowedOrigin
|
|
.map(u => fixUrl(u)?.origin as string)
|
|
.filter(v => !!v),
|
|
...this.url.allowedOrigins,
|
|
];
|
|
}
|
|
|
|
@OnEvent('config.changed')
|
|
onConfigChanged(event: Events['config.changed']) {
|
|
if ('worker' in event.updates) {
|
|
this.onConfigInit();
|
|
}
|
|
}
|
|
}
|