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
+8
View File
@@ -150,6 +150,8 @@ export const createServer = async () => {
return api;
}
console.log(`[DEBUG] No API found, lookup for ${url.pathname}`);
if (g.deploy.router) {
const found = g.deploy.router.lookup(url.pathname);
if (found) {
@@ -161,10 +163,14 @@ export const createServer = async () => {
});
}
console.log(`[DEBUG] No route found, check content for ${url.pathname}`);
if (g.deploy.content) {
const core = g.deploy.content.code.core;
const site = g.deploy.content.code.site;
const pub = g.deploy.content.public;
//list all content
// console.log(`[DEBUG] Content paths: core=${Object.keys(core).join(", ")}, site=${Object.keys(site).join(", ")}, pub=${Object.keys(pub).join(", ")}`);
let pathname = url.pathname;
if (url.pathname[0] === "/") pathname = pathname.substring(1);
@@ -188,6 +194,8 @@ export const createServer = async () => {
else if (site[pathname]) content = site[pathname];
else if (pub[pathname]) content = pub[pathname];
if (content) {
return await serveWeb({
content,
+1
View File
@@ -2,6 +2,7 @@ import { createResponse } from "service-srv";
import { g } from "../utils/global";
export const serveAPI = async (url: URL, req: Request) => {
console.log(`[DEBUG] serveAPI called with pathname: ${url.pathname}`);
let found = g.router.lookup(url.pathname);
if (!found?.url) {
if (!url.pathname.endsWith("/")) {