mirror of
https://github.com/whyour/qinglong.git
synced 2025-12-23 15:50:07 +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 { getPlatform } from '../config/util';
|
||||||
import { shareStore } from '../shared/store';
|
import { shareStore } from '../shared/store';
|
||||||
import { isValidToken } from '../shared/auth';
|
import { isValidToken } from '../shared/auth';
|
||||||
|
import config from '../config';
|
||||||
|
|
||||||
export default async ({ server }: { server: Server }) => {
|
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);
|
const sockService = Container.get(SockService);
|
||||||
|
|
||||||
echo.on('connection', async (conn) => {
|
echo.on('connection', async (conn) => {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ let _request = axios.create({
|
||||||
params: { t: time },
|
params: { t: time },
|
||||||
});
|
});
|
||||||
|
|
||||||
const apiWhiteList = [
|
const apiWhiteListBase = [
|
||||||
'/api/user/login',
|
'/api/user/login',
|
||||||
'/open/auth/token',
|
'/open/auth/token',
|
||||||
'/api/user/two-factor/login',
|
'/api/user/two-factor/login',
|
||||||
|
|
@ -92,6 +92,8 @@ const apiWhiteList = [
|
||||||
'/api/user/notification/init',
|
'/api/user/notification/init',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const apiWhiteList = apiWhiteListBase.map(path => `${config.baseUrl}${path.replace(/^\//, '')}`);
|
||||||
|
|
||||||
_request.interceptors.request.use((_config) => {
|
_request.interceptors.request.use((_config) => {
|
||||||
const token = localStorage.getItem(config.authKey);
|
const token = localStorage.getItem(config.authKey);
|
||||||
if (token && !apiWhiteList.includes(_config.url!)) {
|
if (token && !apiWhiteList.includes(_config.url!)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user