mirror of
https://github.com/strapi/strapi.git
synced 2025-11-11 07:39:16 +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);
|
const vite = await createServer(finalConfig);
|
||||||
|
|
||||||
ctx.strapi.server.app.use(async (ctx, next) => {
|
ctx.strapi.server.app.use((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) => {
|
return new Promise((resolve, reject) => {
|
||||||
vite.middlewares(ctx.req, ctx.res, (err: unknown) => {
|
vite.middlewares(ctx.req, ctx.res, (err: unknown) => {
|
||||||
if (err) reject(err);
|
if (err) {
|
||||||
else resolve(next());
|
reject(err);
|
||||||
});
|
} else {
|
||||||
});
|
resolve(next());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
await next();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const serveAdmin: Common.MiddlewareHandler = async (koaCtx, next) => {
|
const serveAdmin: Common.MiddlewareHandler = async (koaCtx, next) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user