Commit 6308992e authored by Grant's avatar Grant
Browse files

fix admin UI serve

parent f567e7ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ RUN npm -w packages/client run build

# --- build admin ---

ENV APP_ROOT /admin
RUN npm -w packages/admin run build

# --- build server ---
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ const router = createBrowserRouter(
    },
  ],
  {
    basename: import.meta.env.VITE_APP_ROOT,
    basename: __APP_ROOT__,
  }
);

+2 −0
Original line number Diff line number Diff line
/// <reference types="vite/client" />

declare const __APP_ROOT__: string;
+3 −0
Original line number Diff line number Diff line
@@ -15,4 +15,7 @@ export default defineConfig({
      include: "**/*.{jsx,tsx}",
    }),
  ],
  define: {
    __APP_ROOT__: JSON.stringify(process.env.APP_ROOT),
  },
});
+4 −8
Original line number Diff line number Diff line
@@ -69,17 +69,13 @@ export class ExpressServer {
      // client is needing to serve
      Logger.info(
        "Serving admin UI at /admin using root " +
          path.join(__dirname, process.env.SERVE_ADMIN)
      );
      const assetsDir = path.join(__dirname, process.env.SERVE_ADMIN, "assets");
      const indexFile = path.join(
        __dirname,
        process.env.SERVE_ADMIN,
        "index.html"
          path.join(process.env.SERVE_ADMIN)
      );
      const assetsDir = path.join(process.env.SERVE_ADMIN, "assets");
      const indexFile = path.join(process.env.SERVE_ADMIN, "index.html");

      this.app.use("/admin/assets", express.static(assetsDir));
      this.app.use("/admin/*", (req, res) => {
      this.app.use("/admin*", (req, res) => {
        res.sendFile(indexFile);
      });
    }