mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
fix: failed to dynamically load chunk (#19821)
This commit is contained in:
parent
1cb89ea8d0
commit
1e7fe8ee8c
@ -20,23 +20,16 @@ const watch = async (ctx: BuildContext): Promise<ViteWatcher> => {
|
||||
|
||||
const vite = await createServer(finalConfig);
|
||||
|
||||
ctx.strapi.server.app.use(async (ctx, next) => {
|
||||
const url = ctx.url;
|
||||
|
||||
// Check if the URL points to a file that Vite can handle
|
||||
const file = await vite.moduleGraph.getModuleByUrl(url);
|
||||
|
||||
if (file || url.startsWith('/@')) {
|
||||
// If Vite can handle the file, pass the request to the Vite middleware
|
||||
return new Promise((resolve, reject) => {
|
||||
vite.middlewares(ctx.req, ctx.res, (err: unknown) => {
|
||||
if (err) reject(err);
|
||||
else resolve(next());
|
||||
});
|
||||
ctx.strapi.server.app.use((ctx, next) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
vite.middlewares(ctx.req, ctx.res, (err: unknown) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(next());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await next();
|
||||
});
|
||||
});
|
||||
|
||||
const serveAdmin: Common.MiddlewareHandler = async (koaCtx, next) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user