fix: skip auth header on unprotected health status endpoint

This commit is contained in:
Gabriel Santana de Menezes 2026-05-15 15:39:32 -04:00
parent 9ba47e0ae5
commit 02b8556b02
2 changed files with 9 additions and 5 deletions

View file

@ -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,

View file

@ -16,5 +16,6 @@ export type BackendHealthResponse = {
export async function getBackendStatus() {
return apiFetch<BackendHealthResponse>("/q/status", {
method: "GET",
skipAuth: true,
});
}