import { Query } from '@kevisual/query/query'; import { getConfig } from './get-config.ts'; const config = getConfig(); export const baseURL = config?.baseURL || 'https://envision.xiongxiao.me'; export const getBaseURL = () => { if (typeof config?.dev === 'undefined') { return baseURL; } if (typeof config?.dev === 'string') { if (config?.dev === 'true') { return 'http://localhost:4002'; } return baseURL; } if (config?.dev === true) { return 'http://localhost:4002'; } return baseURL; }; export const query = new Query({ url: `${getBaseURL()}/api/router`, }); query.beforeRequest = async (config) => { if (config.headers) { const token = await getConfig()?.token; if (token) { config.headers['Authorization'] = 'Bearer ' + token; } } return config; };