refactor: simplify auth and subscription links
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
import axios from 'axios'
|
||||
import { getEffectiveToken, clearToken } from '@/utils/token'
|
||||
|
||||
// Read runtime config (injected by config.js, defaults to same-origin)
|
||||
const apiBaseUrl = (window.SUB_STORE_CONFIG?.apiBaseUrl) || ''
|
||||
import { getApiBaseUrl, getEffectiveToken, clearToken } from '@/utils/token'
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: apiBaseUrl + '/api',
|
||||
timeout: 30000,
|
||||
})
|
||||
|
||||
// Request interceptor — attach admin token
|
||||
api.interceptors.request.use((config) => {
|
||||
config.baseURL = `${getApiBaseUrl()}/api`
|
||||
const token = getEffectiveToken()
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
@@ -68,12 +65,6 @@ export const getTemplate = (name) => api.get(`/templates/${name}`)
|
||||
export const updateTemplate = (name, data) => api.patch(`/templates/${name}`, data)
|
||||
export const deleteTemplate = (name) => api.delete(`/templates/${name}`)
|
||||
|
||||
// Shares
|
||||
export const listShares = () => api.get('/shares')
|
||||
export const createShare = (data) => api.post('/shares', data)
|
||||
export const updateShare = (id, data) => api.patch(`/shares/${id}`, data)
|
||||
export const deleteShare = (id) => api.delete(`/shares/${id}`)
|
||||
|
||||
// Recycle bin
|
||||
export const listRecycleBin = () => api.get('/recycle-bin')
|
||||
export const deleteRecycleEntry = (id) => api.delete(`/recycle-bin/${id}`)
|
||||
@@ -93,6 +84,7 @@ export const getFlowInfo = (name) => api.get(`/source/flow/${name}`)
|
||||
// Tools
|
||||
export const parseProxy = (data) => api.post('/proxy/parse', data)
|
||||
export const parseRule = (data) => api.post('/rule/parse', data)
|
||||
export const exportProxyUri = (node) => api.post('/utils/proxy-uri', node)
|
||||
export const getNodeInfo = (server) => api.post('/utils/node-info', { server })
|
||||
|
||||
export default api
|
||||
|
||||
Reference in New Issue
Block a user