fix: skip auth header on unprotected health status endpoint

fix: skip auth header on unprotected health status endpoint
This commit is contained in:
Gabriel Menezes 2026-05-15 15:46:32 -04:00 committed by GitHub
commit 16529fafa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -6,16 +6,19 @@ 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 (storedUser) {
const userData = JSON.parse(storedUser)
authHeader = { 'Authorization': `Bearer ${userData.jwt}` }
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), {

View file

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