mirror of
https://github.com/ArthurDanjou/website-old.git
synced 2026-01-14 12:14:42 +01:00
Add maintenance test
This commit is contained in:
@@ -2,13 +2,17 @@ import {Context} from "@nuxt/types";
|
|||||||
|
|
||||||
export default async function ({redirect, route, $axios}: Context) {
|
export default async function ({redirect, route, $axios}: Context) {
|
||||||
let isMaintenance = true
|
let isMaintenance = true
|
||||||
const response = await $axios.get('/api/maintenance', {
|
try {
|
||||||
headers: {
|
const response = await $axios.get('/api/maintenance', {
|
||||||
'Authorization': `Bearer ${process.env.API_TOKEN}`
|
headers: {
|
||||||
|
'Authorization': `Bearer ${process.env.API_TOKEN}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (response.status === 200) {
|
||||||
|
isMaintenance = response.data.maintenance.active === 1
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
if (response.status === 200) {
|
return redirect('/maintenance')
|
||||||
isMaintenance = response.data.maintenance.active === 1
|
|
||||||
}
|
}
|
||||||
if (isMaintenance) {
|
if (isMaintenance) {
|
||||||
return redirect('/maintenance')
|
return redirect('/maintenance')
|
||||||
|
|||||||
Reference in New Issue
Block a user