fix
This commit is contained in:
+6
-1
@@ -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") || ""
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user