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) {
|
||||
let isMaintenance = true
|
||||
const response = await $axios.get('/api/maintenance', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${process.env.API_TOKEN}`
|
||||
try {
|
||||
const response = await $axios.get('/api/maintenance', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${process.env.API_TOKEN}`
|
||||
}
|
||||
})
|
||||
if (response.status === 200) {
|
||||
isMaintenance = response.data.maintenance.active === 1
|
||||
}
|
||||
})
|
||||
if (response.status === 200) {
|
||||
isMaintenance = response.data.maintenance.active === 1
|
||||
} catch (error) {
|
||||
return redirect('/maintenance')
|
||||
}
|
||||
if (isMaintenance) {
|
||||
return redirect('/maintenance')
|
||||
|
||||
Reference in New Issue
Block a user