Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit dd224a3

Browse files
committed
fix: update js paths
1 parent 6cc2d57 commit dd224a3

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

redisinsight/api/src/middleware/subpath-proxy.middleware.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,27 @@ export default class SubpathProxyMiddleware implements NestMiddleware {
88
async use(req: Request, res: Response, next: NextFunction) {
99
const originalSendFile = res.sendFile;
1010
const proxyPath = trim(process.env.RI_PROXY_PATH, '/');
11-
res.sendFile = function (this: Response, path: string, options: any, callback?: (err?: Error) => void) {
12-
if (path.endsWith('.html') || path.endsWith('.js')) {
11+
res.sendFile = function (
12+
this: Response,
13+
path: string,
14+
options: any,
15+
callback?: (err?: Error) => void,
16+
) {
17+
if (
18+
path.endsWith('.html') ||
19+
path.endsWith('.js') ||
20+
path.endsWith('.css') ||
21+
path.includes('.js?v=')
22+
) {
1323
let content = fs.readFileSync(path, 'utf8');
1424
const regex = /\/?__RIPROXYPATH__/g;
1525

26+
// Fix dynamic imports paths
27+
if (path.endsWith('.js')) {
28+
// Fix paths for dynamic imports
29+
content = content.replace(/\/assets\/assets\//g, '/assets/');
30+
}
31+
1632
// for vite build proxyPath if exists should starts with '/'
1733
content = content.replace(regex, proxyPath ? '/' + proxyPath : '');
1834
res.send(content);

0 commit comments

Comments
 (0)