mirror of
https://github.com/whyour/qinglong.git
synced 2025-12-23 15:40:44 +08:00
Update websocket and frontend to support base URL
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
f5f9d464cb
commit
10f19a5c1d
|
|
@ -5,9 +5,10 @@ import SockService from '../services/sock';
|
|||
import { getPlatform } from '../config/util';
|
||||
import { shareStore } from '../shared/store';
|
||||
import { isValidToken } from '../shared/auth';
|
||||
import config from '../config';
|
||||
|
||||
export default async ({ server }: { server: Server }) => {
|
||||
const echo = sockJs.createServer({ prefix: '/api/ws', log: () => {} });
|
||||
const echo = sockJs.createServer({ prefix: `${config.baseUrl}/api/ws`, log: () => {} });
|
||||
const sockService = Container.get(SockService);
|
||||
|
||||
echo.on('connection', async (conn) => {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ let _request = axios.create({
|
|||
params: { t: time },
|
||||
});
|
||||
|
||||
const apiWhiteList = [
|
||||
const apiWhiteListBase = [
|
||||
'/api/user/login',
|
||||
'/open/auth/token',
|
||||
'/api/user/two-factor/login',
|
||||
|
|
@ -92,6 +92,8 @@ const apiWhiteList = [
|
|||
'/api/user/notification/init',
|
||||
];
|
||||
|
||||
const apiWhiteList = apiWhiteListBase.map(path => `${config.baseUrl}${path.replace(/^\//, '')}`);
|
||||
|
||||
_request.interceptors.request.use((_config) => {
|
||||
const token = localStorage.getItem(config.authKey);
|
||||
if (token && !apiWhiteList.includes(_config.url!)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user