fix: 更新依赖项版本并优化远程应用连接逻辑

This commit is contained in:
2026-02-21 06:28:20 +08:00
parent 68c1976754
commit 13b0f45d3e
13 changed files with 184 additions and 76 deletions

View File

@@ -1,5 +1,4 @@
import { useKey } from '@kevisual/use-config';
import http from 'node:http';
import { IncomingMessage } from 'node:http';
export const error = (msg: string, code = 500) => {
return JSON.stringify({ code, message: msg });
};
@@ -16,7 +15,12 @@ const cookie = {
return cookies;
}
}
export const getToken = async (req: http.IncomingMessage) => {
/**
* 从请求中获取token优先级Authorization header > query parameter > cookie
* @param req
* @returns
*/
export const getToken = async (req: IncomingMessage) => {
let token = (req.headers?.['authorization'] as string) || (req.headers?.['Authorization'] as string) || '';
const url = new URL(req.url || '', 'http://localhost');
if (!token) {
@@ -31,9 +35,4 @@ export const getToken = async (req: http.IncomingMessage) => {
}
return { token };
};
export const getEnvToken = () => {
const envTokne = useKey('KEVISUAL_TOKEN') || '';
return envTokne;
}
};