Переглянути джерело

Merge pull request #22481 from overleaf/bg-fix-blob-redirect-middleware

fix fileToBlobRedirectMiddleware internal redirect

GitOrigin-RevId: 874196d58f8b657d73a8e7f1ea4fef8290d48a10
Brian Gough 1 рік тому
батько
коміт
000017ecde

+ 6 - 4
services/web/app/src/Features/History/HistoryController.js

@@ -85,14 +85,16 @@ module.exports = HistoryController = {
         if (err) {
           return next(err)
         }
-        if (file?.hash) {
-          req.url = `/project/${projectId}/blob/${file.hash}`
-        }
         metrics.inc('fileToBlobRedirectMiddleware', 1, {
           method: req.method,
           status: Boolean(file?.hash),
         })
-        next()
+        if (file?.hash) {
+          req.url = `/project/${projectId}/blob/${file.hash}`
+          next('route') // redirect to blob route
+        } else {
+          next() // continue with file route
+        }
       }
     )
   },