|
1 | 1 | import { env } from '$env/dynamic/private'; |
| 2 | +import { getServerInfo } from '$lib/server/api/alive'; |
2 | 3 | import { getCurrentUser } from '$lib/server/api/auth_api'; |
3 | 4 | import { getLogger } from '$lib/server/logger.js'; |
4 | 5 | import { error, redirect } from '@sveltejs/kit'; |
@@ -64,7 +65,8 @@ export async function handle({ event, resolve }) { |
64 | 65 |
|
65 | 66 | const isPublicPage = |
66 | 67 | event.url.pathname == '/' || |
67 | | - event.url.pathname.startsWith('/auth'); |
| 68 | + event.url.pathname.startsWith('/auth') || |
| 69 | + event.url.pathname.startsWith('/alive'); |
68 | 70 |
|
69 | 71 | if (isPublicPage) { |
70 | 72 | logger.debug('Public page - No auth required'); |
@@ -109,31 +111,6 @@ export async function handleFetch({ event, request, fetch }) { |
109 | 111 | return fetch(request); |
110 | 112 | } |
111 | 113 |
|
112 | | -/** |
113 | | - * @param {typeof fetch} fetch |
114 | | - * @returns {Promise<{ alive: boolean, version: string | null }>} |
115 | | - */ |
116 | | -async function getServerInfo(fetch) { |
117 | | - let serverInfo = { alive: false, version: null }; |
118 | | - |
119 | | - try { |
120 | | - const serverInfoResponse = await fetch(env.FRACTAL_SERVER_HOST + '/api/alive/'); |
121 | | - if (serverInfoResponse.ok) { |
122 | | - serverInfo = await serverInfoResponse.json(); |
123 | | - logger.debug('Server info loaded: Alive %s - %s', serverInfo.alive, serverInfo.version); |
124 | | - } else { |
125 | | - logger.error( |
126 | | - 'Alive endpoint replied with unsuccessful status code %d', |
127 | | - serverInfoResponse.status |
128 | | - ); |
129 | | - } |
130 | | - } catch (error) { |
131 | | - logger.fatal('Error loading server info', error); |
132 | | - } |
133 | | - |
134 | | - return serverInfo; |
135 | | -} |
136 | | - |
137 | 114 | /** |
138 | 115 | * @param {typeof fetch} fetch |
139 | 116 | * @returns {Promise<import('$lib/types').User|null>} |
|
0 commit comments