feat(frontend): apply API key headers to center auth client
This commit is contained in:
@@ -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> {
|
||||||
|
|||||||
Reference in New Issue
Block a user