From 373bd9b962ce50af6d938b9cb68d090f95c88704 Mon Sep 17 00:00:00 2001
From: Domingos Panta <up202001536@fe.up.pt>
Date: Wed, 11 May 2022 17:56:31 +0100
Subject: [PATCH 1/4] Added response interceptor to axios response.

This interceptor checks for response code 404 and redicts the user if that is the case.
---
 src/mixins/public.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/mixins/public.js b/src/mixins/public.js
index a3e12f460..16b60129b 100644
--- a/src/mixins/public.js
+++ b/src/mixins/public.js
@@ -7,6 +7,17 @@ if (env === "development" || localStorage.dev === "dev") {
     axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
 }
 
+// Add a response interceptor to catch 404 errors in dymanic routes such as /status/:slug
+axios.interceptors.response.use(function (response) {
+    return response;
+}, function (error) {
+    if(error.response.status === 404){
+        location.href = "/page-not-found";
+    }
+    console.log(error);
+    return Promise.reject(error);
+});
+
 export default {
     data() {
         return {

From fdd781b08172647d4eaf259119c95d813f88c24d Mon Sep 17 00:00:00 2001
From: Domingos Panta <up202001536@fe.up.pt>
Date: Wed, 11 May 2022 17:57:25 +0100
Subject: [PATCH 2/4] Added a link to the home page on the lists of actions. s
 new link was necessary to prevent a loop when the user tries to access a
 unknown resource, like status/123, and was redirected to /page-not-found. In
 this case going back to the last page would be /status/123 which does not
 exists.

---
 src/pages/NotFound.vue | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/pages/NotFound.vue b/src/pages/NotFound.vue
index 16ba8a558..1744ee8a8 100644
--- a/src/pages/NotFound.vue
+++ b/src/pages/NotFound.vue
@@ -32,6 +32,7 @@
                 <ul>
                     <li>Retype the address.</li>
                     <li><a href="#" class="go-back" @click="goBack()">Go back to the previous page.</a></li>
+                    <li><a href="/" class="go-back">Go back to home page.</a></li>
                 </ul>
             </div>
         </div>

From 668e97c5a9756fa8a8acccdd5948418f727a6552 Mon Sep 17 00:00:00 2001
From: Domingos Panta <up202001536@fe.up.pt>
Date: Thu, 12 May 2022 13:39:10 +0100
Subject: [PATCH 3/4] fix: lint errors.

---
 src/mixins/public.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mixins/public.js b/src/mixins/public.js
index 16b60129b..b9a1470d9 100644
--- a/src/mixins/public.js
+++ b/src/mixins/public.js
@@ -11,7 +11,7 @@ if (env === "development" || localStorage.dev === "dev") {
 axios.interceptors.response.use(function (response) {
     return response;
 }, function (error) {
-    if(error.response.status === 404){
+    if (error.response.status === 404) {
         location.href = "/page-not-found";
     }
     console.log(error);

From 7cc89979f0a2883d929c77eddaebb2c787a97bd2 Mon Sep 17 00:00:00 2001
From: Domingos Panta <up202001536@fe.up.pt>
Date: Thu, 12 May 2022 15:52:21 +0100
Subject: [PATCH 4/4] Moving change from axios interceptor to specific request.

---
 src/mixins/public.js     | 11 -----------
 src/pages/StatusPage.vue |  5 +++++
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/mixins/public.js b/src/mixins/public.js
index b9a1470d9..a3e12f460 100644
--- a/src/mixins/public.js
+++ b/src/mixins/public.js
@@ -7,17 +7,6 @@ if (env === "development" || localStorage.dev === "dev") {
     axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
 }
 
-// Add a response interceptor to catch 404 errors in dymanic routes such as /status/:slug
-axios.interceptors.response.use(function (response) {
-    return response;
-}, function (error) {
-    if (error.response.status === 404) {
-        location.href = "/page-not-found";
-    }
-    console.log(error);
-    return Promise.reject(error);
-});
-
 export default {
     data() {
         return {
diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue
index 8cda7ebba..1c40016c3 100644
--- a/src/pages/StatusPage.vue
+++ b/src/pages/StatusPage.vue
@@ -551,6 +551,11 @@ export default {
 
             this.incident = res.data.incident;
             this.$root.publicGroupList = res.data.publicGroupList;
+        }).catch( function (error) {
+            if (error.response.status === 404) {
+                location.href = "/page-not-found";
+            }
+            console.log(error);
         });
 
         // 5mins a loop