mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
chore: improve cors
This commit is contained in:
@@ -6,6 +6,8 @@ import { TelemetryDeduper } from './deduper';
|
||||
import { Ga4Client } from './ga4-client';
|
||||
import { TelemetryAck, TelemetryBatch } from './types';
|
||||
|
||||
const TELEMETRY_ROUTE_PATTERN = /\/api\/telemetry(?:\/|$)/;
|
||||
|
||||
@Injectable()
|
||||
export class TelemetryService {
|
||||
private readonly logger = new Logger(TelemetryService.name);
|
||||
@@ -71,6 +73,13 @@ export class TelemetryService {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAllowedOrigins(routePath?: string): string[] {
|
||||
if (routePath && TELEMETRY_ROUTE_PATTERN.test(routePath)) {
|
||||
return [...this.allowedOrigins];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async collectBatch(batch: TelemetryBatch): Promise<TelemetryAck> {
|
||||
if (!batch || batch.schemaVersion !== 1 || !Array.isArray(batch.events)) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user