mirror of
https://github.com/RSSNext/Folo.git
synced 2026-10-17 05:08:13 +08:00
81c5b9f2e0
* chore(infra): migrate desktop web from Vercel to Cloudflare Workers Replaces separate Vercel deployments (follow SPA + follow-external-ssr) with unified Cloudflare Workers + Assets deployment. Implements meta tag injection, OG image generation, and environment variable management in Hono-based Worker. Adds GitHub Actions CI/CD for automatic deployment on push to dev/main branches. - Replace Fastify with Hono for Cloudflare Workers compatibility - Create Worker entry point with SSR routes and SPA fallback - Add AsyncLocalStorage-based request context shim - Implement WASM-based OG image rendering with R2 font storage - Split SPA and SSR routing: /share/* and auth routes use SSR, others fallback to SPA - Add Cloudflare wrangler configuration with dev/prod environments - Create GitHub Actions workflow for automated deployments - Add build scripts for font data and WASM patching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ssr): exclude worker files from typecheck and fix tsdown config Worker-specific files (*.worker.ts) use Cloudflare Workers types and generated modules that aren't available during the main tsc typecheck. Exclude them from tsconfig since they're only used via tsdown aliases. Also fix broken path.resolve reference in tsdown.worker.config.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
772 B
TypeScript
25 lines
772 B
TypeScript
import fs from "node:fs"
|
|
|
|
import { dirname, join } from "pathe"
|
|
|
|
const distDir = join(dirname(import.meta.url.replace("file://", "")), "../dist/worker")
|
|
|
|
const files = fs.readdirSync(distDir).filter((f) => f.endsWith(".mjs"))
|
|
|
|
for (const file of files) {
|
|
const filePath = join(distDir, file)
|
|
const code = fs.readFileSync(filePath, "utf-8")
|
|
|
|
// Fix createRequire(import.meta.url) - import.meta.url is undefined in Cloudflare Workers
|
|
// Provide a fallback URL so createRequire can initialize properly
|
|
const patched = code.replaceAll(
|
|
"createRequire(import.meta.url)",
|
|
'createRequire(import.meta.url || "file:///worker.mjs")',
|
|
)
|
|
|
|
if (patched !== code) {
|
|
fs.writeFileSync(filePath, patched)
|
|
console.info(`Patched createRequire in ${file}`)
|
|
}
|
|
}
|