fix admin UI serve
This commit is contained in:
parent
f567e7abd1
commit
6308992e02
|
@ -55,6 +55,7 @@ RUN npm -w packages/client run build
|
||||||
|
|
||||||
# --- build admin ---
|
# --- build admin ---
|
||||||
|
|
||||||
|
ENV APP_ROOT /admin
|
||||||
RUN npm -w packages/admin run build
|
RUN npm -w packages/admin run build
|
||||||
|
|
||||||
# --- build server ---
|
# --- build server ---
|
||||||
|
|
|
@ -31,7 +31,7 @@ const router = createBrowserRouter(
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
basename: import.meta.env.VITE_APP_ROOT,
|
basename: __APP_ROOT__,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare const __APP_ROOT__: string;
|
||||||
|
|
|
@ -15,4 +15,7 @@ export default defineConfig({
|
||||||
include: "**/*.{jsx,tsx}",
|
include: "**/*.{jsx,tsx}",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
define: {
|
||||||
|
__APP_ROOT__: JSON.stringify(process.env.APP_ROOT),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,17 +69,13 @@ export class ExpressServer {
|
||||||
// client is needing to serve
|
// client is needing to serve
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"Serving admin UI at /admin using root " +
|
"Serving admin UI at /admin using root " +
|
||||||
path.join(__dirname, process.env.SERVE_ADMIN)
|
path.join(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"
|
|
||||||
);
|
);
|
||||||
|
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/assets", express.static(assetsDir));
|
||||||
this.app.use("/admin/*", (req, res) => {
|
this.app.use("/admin*", (req, res) => {
|
||||||
res.sendFile(indexFile);
|
res.sendFile(indexFile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue