diff --git a/app/srv/api/prod.ts b/app/srv/api/prod.ts
index 1e58d607..0eaa2efe 100644
--- a/app/srv/api/prod.ts
+++ b/app/srv/api/prod.ts
@@ -3,6 +3,7 @@ import { apiContext } from "service-srv";
import { validate } from "uuid";
import { code } from "../ws/sync/editor/code/util-code";
import { gzipAsync } from "../ws/sync/entity/zlib";
+import { prodIndex } from "../util/prod-index";
export const _ = {
url: "/prod/:site_id/**",
@@ -12,26 +13,9 @@ export const _ = {
const pathname: string = req.params["*"] || "";
const site_id = req.params.site_id as string;
- const index_html = new Response(
- `\
-
-
-
-
-
-
-
-
-
-
-
-
-
-`,
- { headers: { "content-type": "text/html" } }
- );
+ const index_html = new Response(prodIndex(site_id).render(), {
+ headers: { "content-type": "text/html" },
+ });
if (!validate(site_id))
return new Response("site not found", { status: 403 });
diff --git a/app/srv/util/prod-index.ts b/app/srv/util/prod-index.ts
new file mode 100644
index 00000000..be900ae3
--- /dev/null
+++ b/app/srv/util/prod-index.ts
@@ -0,0 +1,30 @@
+export const prodIndex = (site_id: string) => {
+ return {
+ head: [] as string[],
+ body: [] as string[],
+ render() {
+ return `\
+
+
+
+
+
+
+
+ ${this.head.join("\n")}
+
+
+
+ ${this.body.join("\n")}
+
+
+
+
+
+`;
+ },
+ };
+};
diff --git a/app/srv/ws/sync/actions/code_action.ts b/app/srv/ws/sync/actions/code_action.ts
index 2a682fd0..5c5f1bff 100644
--- a/app/srv/ws/sync/actions/code_action.ts
+++ b/app/srv/ws/sync/actions/code_action.ts
@@ -123,7 +123,9 @@ declare global {
url: URL;
req: Request;
server: Server;
+ mode: "dev" | "prod";
handle: (req: Request) => Promise;
+ index: { head: string[]; body: string[]; render: () => string };
}) => Promise;
};
}
diff --git a/app/srv/ws/sync/editor/code/build-code.ts b/app/srv/ws/sync/editor/code/build-code.ts
index f14379b5..dfafc8e9 100644
--- a/app/srv/ws/sync/editor/code/build-code.ts
+++ b/app/srv/ws/sync/editor/code/build-code.ts
@@ -24,7 +24,7 @@ export const codeBuild = async (id_site: any) => {
import type {} from "./typings/global";
export const server: PrasiServer = {
- async http({ req, handle, url, server }) {
+ async http({ req, handle, mode, url, index, server }) {
return await handle(req);
},
};
diff --git a/app/srv/ws/sync/editor/code/server-main.ts b/app/srv/ws/sync/editor/code/server-main.ts
index e5d2a2a3..f1e7ab61 100644
--- a/app/srv/ws/sync/editor/code/server-main.ts
+++ b/app/srv/ws/sync/editor/code/server-main.ts
@@ -6,6 +6,7 @@ import { waitUntil } from "web-utils";
import { code } from "./util-code";
import { WSData } from "../../../../../../pkgs/core/server/create";
import { codeBuild } from "./build-code";
+import { prodIndex } from "../../../../util/prod-index";
const serverMain = () => ({
handler: {} as Record,
@@ -85,7 +86,11 @@ const serverMain = () => ({
return new Response("Upgrade failed :(", { status: 500 });
}
- return await handler.http(arg);
+ return await handler.http({
+ ...arg,
+ mode: "dev",
+ index: prodIndex(site_id),
+ });
} catch (e: any) {
_fs.appendFile(
code.path(site_id, "site", "src", "server.log"),
@@ -103,6 +108,8 @@ type PrasiServer = {
req: Request;
server: Server;
handle: (req: Request) => Promise;
+ mode: "dev" | "prod";
+ index: { head: string[]; body: string[]; render: () => string };
}) => Promise;
};
diff --git a/app/web/src/nova/ed/panel/popup/api/api-server.tsx b/app/web/src/nova/ed/panel/popup/api/api-server.tsx
index b48de64f..f5aeb42b 100644
--- a/app/web/src/nova/ed/panel/popup/api/api-server.tsx
+++ b/app/web/src/nova/ed/panel/popup/api/api-server.tsx
@@ -103,7 +103,7 @@ export const EdApiServer = forwardRef<
server.status = "saving";
p.render();
p.site.config.api_url = trim(local.api_url, "/");
- await p.sync.site.update(p.site.id, {
+ await p.sync?.site.update(p.site.id, {
config: { api_url: local.api_url },
});
}
@@ -254,7 +254,6 @@ export const EdApiServer = forwardRef<
)}
{local.deployable && (
<>
-
>
)}