feat: add tenant-router Cloudflare Worker with routing for classroomio domains and update dependencies

This commit is contained in:
Rotimi Best
2026-05-19 23:53:51 +01:00
parent 0f388ae0d3
commit bad837a4cb
13 changed files with 225 additions and 37 deletions
-1
View File
@@ -11,7 +11,6 @@ const envSchema = z.object({
CLOUDFLARE_CUSTOM_HOSTNAMES_API_TOKEN: z.string().optional(),
CLOUDFLARE_CUSTOM_HOSTNAMES_ZONE_ID: z.string().optional(),
CLOUDFLARE_CUSTOM_HOSTNAME_CNAME_TARGET: z.string().optional(),
CLOUDFLARE_CUSTOM_HOSTNAME_ORIGIN: z.string().optional(),
// S3-compatible storage (MinIO, AWS S3, or other S3-compatible backends)
OBJECT_STORAGE_ENDPOINT: z.string().optional(),
OBJECT_STORAGE_REGION: z.string().optional(),
+1 -1
View File
@@ -6,7 +6,7 @@ export const API_PORT = env.PORT ? parseInt(env.PORT) : 3002;
export const API_SERVER_URL = env.PUBLIC_SERVER_URL || `http://localhost:${API_PORT}`;
export const TRUSTED_ORIGINS = env.TRUSTED_ORIGINS
? env.TRUSTED_ORIGINS.split(',')
: ['http://localhost:5173', 'http://localhost:5180', 'https://*.classroomio.com'];
: ['http://localhost:5173', 'http://localhost:5180', 'https://*.classroomio.com', 'https://*.classroomio.school'];
const {
CLOUDFLARE_BUCKET_DOMAIN,
+8 -14
View File
@@ -238,7 +238,7 @@ export function assertSupportedCustomDomain(domain: string) {
);
}
if (domain.includes('classroomio.com')) {
if (domain.includes('classroomio.com') || domain.includes('classroomio.school')) {
throw new AppError("Domain cannot contain 'classroomio'", ErrorCodes.VALIDATION_ERROR, 400, 'domain');
}
}
@@ -252,21 +252,15 @@ async function getCustomHostnameByDomain(hostname: string) {
}
async function createCustomHostname(hostname: string) {
const body: Record<string, unknown> = {
hostname,
ssl: {
method: 'txt',
type: 'dv'
}
};
if (env.CLOUDFLARE_CUSTOM_HOSTNAME_ORIGIN) {
body.custom_origin_server = env.CLOUDFLARE_CUSTOM_HOSTNAME_ORIGIN;
}
return cloudflareRequest<CloudflareCustomHostname>('', {
method: 'POST',
body: JSON.stringify(body)
body: JSON.stringify({
hostname,
ssl: {
method: 'txt',
type: 'dv'
}
})
});
}