This commit is contained in:
eko
2025-11-27 19:00:42 +07:00
parent 9bf393fee8
commit 0e85aa93a2
4 changed files with 21 additions and 162 deletions
+6 -1
View File
@@ -11,7 +11,9 @@ const cache = {
export const _ = {
url: "/_prasi/**",
async api() {
const { req, res } = apiContext(this);
console.log(`[DEBUG] _prasi called with pathname: ${req.url}`);
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "content-type");
const gz = g.deploy.content;
@@ -34,13 +36,16 @@ export const _ = {
}
},
code: async () => {
console.log(`[DEBUG] _prasi code called with pathname: ${req.url}`);
if (gz) {
const path = parts.slice(1).join("/");
console.log(`[DEBUG] _prasi code path: ${path}`);
if (gz.code.site[path]) {
const type = mime.getType(path);
console.log(`[DEBUG] _prasi code type: ${type}`);
if (type) res.setHeader("content-type", type);
res.send(
gz.code.site[path],
new TextDecoder().decode(gz.code.site[path]),
req.headers.get("accept-encoding") || ""
);
}