diff --git a/frontend/src/routes/(loggedin)/app/prober/api-handler.js b/frontend/src/routes/(loggedin)/app/prober/api-handler.js index a3e257b..182b7a6 100644 --- a/frontend/src/routes/(loggedin)/app/prober/api-handler.js +++ b/frontend/src/routes/(loggedin)/app/prober/api-handler.js @@ -1,9 +1,14 @@ import { apiUri } from '$lib/utils/common'; +import { goto } from '$app/navigation'; /** @param {import('@vincjo/datatables/remote/state')} state */ export const loadData = async (state) => { const response = await fetch(apiUri(`/api/v1/prober?${getParams(state)}`)); const json = await response.json(); + if (json.data === null) { + goto('/login'); + return; + } state.setTotalRows(json.data.total_rows ?? 0); return json.data.items ?? []; }; diff --git a/handler/routes.go b/handler/routes.go index 032ea5f..1dff19f 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -12,7 +12,7 @@ func AppRoute(app *fiber.App) { func V1Api(app *fiber.App) { v1 := app.Group("/api/v1") - v1.Get("/prober", Prober) + v1.Get("/prober", CookieProtected, Prober) v1.Post("/prober", CookieProtected, Prober) v1.Patch("/prober/:id", CookieProtected, Prober) v1.Delete("/prober/:id", CookieProtected, Prober)