completionId: cgen-c75845fd93d04e16ad89bbc25a976912
cgen-c75845fd93d04e16ad89bbc25a976912
This commit is contained in:
parent
5469b028bd
commit
b638290d74
1 changed files with 10 additions and 14 deletions
|
|
@ -25,8 +25,6 @@ export default defineConfig(({ mode }) => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function expressPlugin(): Plugin {
|
function expressPlugin(): Plugin {
|
||||||
let expressApp: any = null;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "express-plugin",
|
name: "express-plugin",
|
||||||
apply: "serve",
|
apply: "serve",
|
||||||
|
|
@ -34,24 +32,22 @@ function expressPlugin(): Plugin {
|
||||||
try {
|
try {
|
||||||
console.log("[Vite] Loading Express server...");
|
console.log("[Vite] Loading Express server...");
|
||||||
const { createServer } = await import("./server");
|
const { createServer } = await import("./server");
|
||||||
expressApp = createServer();
|
const app = createServer();
|
||||||
console.log("[Vite] Express server created");
|
console.log("[Vite] Express server created, mounting...");
|
||||||
|
|
||||||
// Return middleware hook that runs BEFORE Vite's default handlers
|
// Mount Express as middleware - this handles /api/* routes
|
||||||
return {
|
// Using unshift to add it to the beginning of the middleware chain
|
||||||
pre: [
|
server.middlewares.stack.unshift({
|
||||||
{
|
route: "",
|
||||||
handler: expressApp,
|
handle: app,
|
||||||
ident: "express-api",
|
});
|
||||||
} as any,
|
|
||||||
],
|
console.log("[Vite] Express server mounted successfully");
|
||||||
};
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[Vite] Failed to load Express server:", e instanceof Error ? e.message : String(e));
|
console.error("[Vite] Failed to load Express server:", e instanceof Error ? e.message : String(e));
|
||||||
if (e instanceof Error && e.stack) {
|
if (e instanceof Error && e.stack) {
|
||||||
console.error(e.stack);
|
console.error(e.stack);
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue