add color and routing

This commit is contained in:
2025-06-01 11:43:00 +02:00
parent 03e4a5790a
commit 87865871df
7 changed files with 93 additions and 22 deletions
+30
View File
@@ -0,0 +1,30 @@
export default defineNuxtRouteMiddleware(async (to, _from) => {
const runtimeConfig = useRuntimeConfig()
const code = to.query.code;
if (to.path === "/poll") {
const { error } = await useFetch(`${runtimeConfig.public.apiBase}/check/${code}`);
if (error.value && error.value.statusCode !== 200) {
if(error.value.statusCode == 403){
return navigateTo({path:"/results", query:to.query});
}
throw createError({
statusCode: error.value.statusCode,
statusMessage: error.value.statusMessage,
message: error.value.data.message
});
}
return;
}
if(to.path === "/results"){
return
}
// In a real app you would probably not redirect every route to `/`
// however it is important to check `to.path` before redirecting or you
// might get an infinite redirect loop
if (to.path !== "/") {
return navigateTo("/");
}
});