feat: migrate CozSweet legal documents

This commit is contained in:
Codex
2026-07-29 16:08:43 +08:00
parent c2e4e2763f
commit 8735a88ef6
19 changed files with 2025 additions and 3 deletions
+12
View File
@@ -19,6 +19,13 @@ interface ExecutionContext {
passThroughOnException(): void;
}
const LEGAL_DOCUMENT_REDIRECTS: Record<string, string> = {
"/cozsweet/privacy-policy.html": "/privacy-policy.html",
"/cozsweet/data-deletion.html": "/data-deletion.html",
"/cozsweet/membership-agreement.html": "/membership-agreement.html",
"/cozsweet/auto-renewal-agreement.html": "/auto-renewal-agreement.html",
};
// Image security config. SVG sources with .svg extension auto-skip the
// optimization endpoint on the client side (served directly, no proxy).
// To route SVGs through the optimizer (with security headers), set
@@ -29,6 +36,11 @@ const worker = {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
const legalDocumentPath = LEGAL_DOCUMENT_REDIRECTS[url.pathname];
if (legalDocumentPath) {
return Response.redirect(new URL(legalDocumentPath, request.url), 308);
}
if (url.pathname === "/_vinext/image") {
const allowedWidths = [...DEFAULT_DEVICE_SIZES, ...DEFAULT_IMAGE_SIZES];
return handleImageOptimization(request, {