Summary: - Fix pg-boss queue conflict (duplicate key violation on queue_pkey) - Add global error listener to prevent process crash - Reduce connection pool from 10 to 4 - Add graceful shutdown handling (SIGTERM/SIGINT) - Fix researchWorker recursive call bug in catch block - Make screeningWorker idempotent using upsert Security Standards (v1.1): - Prohibit recursive retry in Worker catch blocks - Prohibit payload bloat (only store fileKey/ID in job.data) - Require Worker idempotency (upsert + unique constraint) - Recommend task-specific expireInSeconds settings - Document graceful shutdown pattern New Features: - PKB signed URL endpoint for document preview/download - pg_bigm installation guide for Docker - Dockerfile.postgres-with-extensions for pgvector + pg_bigm Documentation: - Update Postgres-Only async task processing guide (v1.1) - Add troubleshooting SQL queries - Update safety checklist Tested: Local verification passed
63 lines
1015 B
TypeScript
63 lines
1015 B
TypeScript
/**
|
|
* 带认证的 Axios 实例
|
|
*
|
|
* 自动添加 Authorization header
|
|
*/
|
|
|
|
import axios from 'axios';
|
|
import { getAccessToken } from '../../framework/auth/api';
|
|
|
|
// 创建 axios 实例
|
|
const apiClient = axios.create({
|
|
timeout: 60000, // 60秒超时
|
|
});
|
|
|
|
// 请求拦截器 - 自动添加 Authorization header
|
|
apiClient.interceptors.request.use(
|
|
(config) => {
|
|
const token = getAccessToken();
|
|
if (token) {
|
|
config.headers.Authorization = `Bearer ${token}`;
|
|
}
|
|
return config;
|
|
},
|
|
(error) => {
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
// 响应拦截器 - 处理 401 错误
|
|
apiClient.interceptors.response.use(
|
|
(response) => response,
|
|
(error) => {
|
|
if (error.response?.status === 401) {
|
|
// Token 过期或无效,可以在这里触发登出
|
|
console.warn('[API] 认证失败,请重新登录');
|
|
// 可选:跳转到登录页
|
|
// window.location.href = '/login';
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
export default apiClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|