|
|
@@ -2657,12 +2657,44 @@ export namespace Server {
|
|
|
},
|
|
|
)
|
|
|
.all("/*", async (c) => {
|
|
|
- return proxy(`https://app.opencode.ai${c.req.path}`, {
|
|
|
+ const path = c.req.path
|
|
|
+ const response = await proxy(`https://app.opencode.ai${path}`, {
|
|
|
...c.req,
|
|
|
headers: {
|
|
|
host: "app.opencode.ai",
|
|
|
},
|
|
|
})
|
|
|
+ // Cloudflare doesn't return Content-Type for static assets, so we need to add it
|
|
|
+ const mimeTypes: Record<string, string> = {
|
|
|
+ ".js": "application/javascript",
|
|
|
+ ".mjs": "application/javascript",
|
|
|
+ ".css": "text/css",
|
|
|
+ ".json": "application/json",
|
|
|
+ ".wasm": "application/wasm",
|
|
|
+ ".svg": "image/svg+xml",
|
|
|
+ ".png": "image/png",
|
|
|
+ ".jpg": "image/jpeg",
|
|
|
+ ".jpeg": "image/jpeg",
|
|
|
+ ".gif": "image/gif",
|
|
|
+ ".ico": "image/x-icon",
|
|
|
+ ".webp": "image/webp",
|
|
|
+ ".woff": "font/woff",
|
|
|
+ ".woff2": "font/woff2",
|
|
|
+ ".ttf": "font/ttf",
|
|
|
+ ".eot": "application/vnd.ms-fontobject",
|
|
|
+ }
|
|
|
+ for (const [ext, mime] of Object.entries(mimeTypes)) {
|
|
|
+ if (path.endsWith(ext)) {
|
|
|
+ const headers = new Headers(response.headers)
|
|
|
+ headers.set("Content-Type", mime)
|
|
|
+ return new Response(response.body, {
|
|
|
+ status: response.status,
|
|
|
+ statusText: response.statusText,
|
|
|
+ headers,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return response
|
|
|
}),
|
|
|
)
|
|
|
|