Update websocket and frontend to support base URL

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-22 14:47:34 +00:00
parent f5f9d464cb
commit 10f19a5c1d
2 changed files with 5 additions and 2 deletions

View File

@ -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) => {

View File

@ -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!)) {