feat(frontend): apply API key headers to center auth client

This commit is contained in:
nav
2026-05-13 06:58:18 +00:00
parent edb06a5a31
commit 66c49ff654

View File

@@ -19,10 +19,21 @@ type RefreshResponse = {
function centerClient() { function centerClient() {
const cfg = getRuntimeConfig() const cfg = getRuntimeConfig()
return axios.create({ const client = axios.create({
baseURL: cfg.centerApiBase, baseURL: cfg.centerApiBase,
timeout: 10000, timeout: 10000,
}) })
client.interceptors.request.use((request) => {
const { apiKey } = getRuntimeConfig()
const requestId = crypto.randomUUID()
if (apiKey) request.headers['x-api-key'] = apiKey
request.headers['x-request-id'] = requestId
request.headers['x-client-name'] = 'fabric-frontend'
return request
})
return client
} }
export async function loginCenter(payload: LoginPayload): Promise<AuthSession> { export async function loginCenter(payload: LoginPayload): Promise<AuthSession> {