This commit is contained in:
ditiqi 2025-02-24 09:01:23 +08:00
parent c031e4f1c1
commit 939a313c9e
2 changed files with 23 additions and 14 deletions

View File

@ -1,17 +1,25 @@
import { useCallback, useMemo } from "react";
import { env } from "../env";
export function useLocalSettings() {
const getBaseUrl = useCallback((protocol: string, port: number) => {
return `${protocol}://${env.SERVER_IP}:${port}`;
}, []);
const tusUrl = useMemo(() => getBaseUrl('http', 8080), [getBaseUrl]);
const apiUrl = useMemo(() => getBaseUrl('http', 3000), [getBaseUrl]);
const websocketUrl = useMemo(() => getBaseUrl('ws', 3000), [getBaseUrl]);
const checkIsTusUrl = useCallback((url: string) => {
return url.startsWith(tusUrl)
}, [tusUrl])
const tusUrl = useMemo(() => getBaseUrl("http", 8080), [getBaseUrl]);
const apiUrl = useMemo(
() => getBaseUrl("http", parseInt(env.SERVER_PORT)),
[getBaseUrl]
);
const websocketUrl = useMemo(() => getBaseUrl("ws", 3000), [getBaseUrl]);
const checkIsTusUrl = useCallback(
(url: string) => {
return url.startsWith(tusUrl);
},
[tusUrl]
);
return {
apiUrl, websocketUrl, checkIsTusUrl, tusUrl
}
apiUrl,
websocketUrl,
checkIsTusUrl,
tusUrl,
};
}

View File

@ -101,6 +101,7 @@ server {
internal;
# 代理到认证服务
proxy_pass http://${SERVER_IP}:${SERVER_PORT}/auth/file;
# 请求优化:不传递请求体
proxy_pass_request_body off;
proxy_set_header Content-Length "";