fix: skip auth header on unprotected health status endpoint
fix: skip auth header on unprotected health status endpoint
This commit is contained in:
commit
16529fafa5
2 changed files with 9 additions and 5 deletions
|
|
@ -6,17 +6,20 @@ function buildUrl(path: string) {
|
|||
|
||||
type RequestOptions = Omit<RequestInit, 'body'> & {
|
||||
body?: any
|
||||
skipAuth?: boolean
|
||||
}
|
||||
|
||||
export async function apiFetch<T>(path: string, options: RequestOptions = {}) {
|
||||
const { body, headers, ...rest } = options
|
||||
const { body, headers, skipAuth, ...rest } = options
|
||||
|
||||
const storedUser = localStorage.getItem('user')
|
||||
let authHeader = {}
|
||||
if (!skipAuth) {
|
||||
const storedUser = localStorage.getItem('user')
|
||||
if (storedUser) {
|
||||
const userData = JSON.parse(storedUser)
|
||||
authHeader = { 'Authorization': `Bearer ${userData.jwt}` }
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch(buildUrl(path), {
|
||||
...rest,
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@ export type BackendHealthResponse = {
|
|||
export async function getBackendStatus() {
|
||||
return apiFetch<BackendHealthResponse>("/q/status", {
|
||||
method: "GET",
|
||||
skipAuth: true,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue