fix: add decodeURIComponent
This commit is contained in:
		@@ -223,14 +223,18 @@ export class UserApp {
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
      await redis.set(key, JSON.stringify(value));
 | 
			
		||||
      await redis.set('user:app:exist:' + app + ':' + user, 'index.html||etag||false', 'EX', 60 * 60 * 24 * 7); // 7天
 | 
			
		||||
      const files = value.data.files;
 | 
			
		||||
      const data = {};
 | 
			
		||||
 | 
			
		||||
      let indexHtml = path.join(fileStore, user, app, 'index.html') + '||etag||false';
 | 
			
		||||
      // 将文件名和路径添加到 `data` 对象中
 | 
			
		||||
      files.forEach((file) => {
 | 
			
		||||
        data[file.name] = file.path;
 | 
			
		||||
        if (file.name === 'index.html') {
 | 
			
		||||
          indexHtml = file.path;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      await redis.set('user:app:exist:' + app + ':' + user, indexHtml, 'EX', 60 * 60 * 24 * 7); // 7天
 | 
			
		||||
 | 
			
		||||
      await redis.hset('user:app:set:' + app + ':' + user, data);
 | 
			
		||||
      this.setLoaded('running', 'loaded');
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -200,13 +200,14 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
 | 
			
		||||
    } else {
 | 
			
		||||
      appFileUrl = (url + '').replace(`/${user}/${app}/`, '');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    appFileUrl = decodeURIComponent(appFileUrl); // Decode URL components
 | 
			
		||||
    const appFile = await userApp.getFile(appFileUrl);
 | 
			
		||||
    if (isExist.proxy) {
 | 
			
		||||
      let proxyUrl = appFile || isExist.indexFilePath;
 | 
			
		||||
      if (!proxyUrl.startsWith('http')) {
 | 
			
		||||
        return createNotFoundPage('Invalid proxy url');
 | 
			
		||||
      }
 | 
			
		||||
      console.log('proxyUrl', appFileUrl, proxyUrl);
 | 
			
		||||
      let protocol = proxyUrl.startsWith('https') ? https : http;
 | 
			
		||||
      // 代理
 | 
			
		||||
      const proxyReq = protocol.request(proxyUrl, (proxyRes) => {
 | 
			
		||||
@@ -231,7 +232,8 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
 | 
			
		||||
      // userApp.clearCacheData()
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    console.log('appFile', appFile, appFileUrl);
 | 
			
		||||
    console.log('appFile', appFile, appFileUrl, isExist);
 | 
			
		||||
    // console.log('isExist', isExist);
 | 
			
		||||
    if (!appFile) {
 | 
			
		||||
      const [indexFilePath, etag] = indexFile.split('||');
 | 
			
		||||
      const contentType = getContentType(indexFilePath);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user