mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-06 02:27:19 +00:00
feat: vite dashboard tweaks/fixes
This commit is contained in:
parent
aaac328138
commit
177f13d1fc
16 changed files with 94 additions and 128 deletions
|
@ -2,20 +2,26 @@ import Fastify from "fastify";
|
|||
import fastifyStatic from "@fastify/static";
|
||||
import path from "node:path";
|
||||
|
||||
const fastify = Fastify({ logger: true });
|
||||
const fastify = Fastify({
|
||||
// We already get logs from nginx, so disable here
|
||||
logger: false,
|
||||
});
|
||||
|
||||
fastify.get("/env.js", (req, reply) => {
|
||||
reply.header("Content-Type", "application/javascript; charset=utf8");
|
||||
reply.send(`window.API_URL = ${JSON.stringify(process.env.API_URL)}`);
|
||||
fastify.addHook("preHandler", (req, reply, done) => {
|
||||
if (req.url === "/env.js") {
|
||||
reply.header("Content-Type", "application/javascript; charset=utf8");
|
||||
reply.send(`window.API_URL = ${JSON.stringify(process.env.API_URL)};`);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
fastify.register(fastifyStatic, {
|
||||
root: path.join(__dirname, "dist"),
|
||||
root: path.join(import.meta.dirname, "dist"),
|
||||
wildcard: false,
|
||||
});
|
||||
|
||||
fastify.get("*", (req, reply) => {
|
||||
reply.header("Content-Type", "text/html; charset=utf8").send(indexContent);
|
||||
reply.sendFile("index.html");
|
||||
});
|
||||
|
||||
fastify.listen({ port: 3002, host: '0.0.0.0' }, (err, address) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue