Преглед на файлове

fix: serve absolute urls (#3265)

Jason Rasmussen преди 2 години
родител
ревизия
4c4435bc19
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      server/src/immich/api-v1/asset/asset.service.ts

+ 3 - 1
server/src/immich/api-v1/asset/asset.service.ts

@@ -591,9 +591,11 @@ export class AssetService {
 
   private async sendFile(res: Res, filepath: string): Promise<void> {
     await fs.access(filepath, constants.R_OK);
+    const options = path.isAbsolute(filepath) ? {} : { root: process.cwd() };
+
     res.set('Cache-Control', 'private, max-age=86400, no-transform');
     res.header('Content-Type', mimeTypes.lookup(filepath));
-    res.sendFile(filepath, { root: process.cwd() }, (error: Error) => {
+    res.sendFile(filepath, options, (error: Error) => {
       if (!error) {
         return;
       }