diff --git a/common/env.go b/common/env.go
index 066d71b634..8262fb4de2 100644
--- a/common/env.go
+++ b/common/env.go
@@ -14,6 +14,7 @@ var (
// USer Cookie
USER_KievRPSSecAuth string
USER_RwBf string
+ USER_MUID string
// 访问权限密钥,可选
AUTH_KEY string
AUTH_KEY_COOKIE_NAME = "BingAI_Auth_Key"
@@ -31,6 +32,9 @@ func initEnv() {
AUTH_KEY = os.Getenv("Go_Proxy_BingAI_AUTH_KEY")
// KievRPSSecAuth Cookie
USER_KievRPSSecAuth = os.Getenv("USER_KievRPSSecAuth")
+ // MUID Cookie
+ USER_MUID = os.Getenv("USER_MUID")
+ // _RwBf Cookie
USER_RwBf = os.Getenv("USER_RwBf")
}
diff --git a/common/proxy.go b/common/proxy.go
index cac04f7b84..91dd9d138d 100644
--- a/common/proxy.go
+++ b/common/proxy.go
@@ -57,6 +57,7 @@ var (
USER_TOKEN_COOKIE_NAME = "_U"
USER_KievRPSSecAuth_COOKIE_NAME = "KievRPSSecAuth"
USER_RwBf_COOKIE_NAME = "_RwBf"
+ User_MUID_COOKIE_NAME = "MUID"
RAND_COOKIE_INDEX_NAME = "BingAI_Rand_CK"
RAND_IP_COOKIE_NAME = "BingAI_Rand_IP"
PROXY_WEB_PREFIX_PATH = "/web/"
@@ -100,6 +101,17 @@ func NewSingleHostReverseProxy(target *url.URL) *httputil.ReverseProxy {
}
req.Header.Set("X-Forwarded-For", randIP)
+ ckUserMUID, _ := req.Cookie(User_MUID_COOKIE_NAME)
+ if ckUserMUID == nil || ckUserMUID.Value == "" {
+ if USER_MUID != "" {
+ // 添加 MUID Cookie
+ req.AddCookie(&http.Cookie{
+ Name: User_MUID_COOKIE_NAME,
+ Value: USER_MUID,
+ })
+ }
+ }
+
ckUserKievRPSSecAuth, _ := req.Cookie(USER_KievRPSSecAuth_COOKIE_NAME)
if ckUserKievRPSSecAuth == nil || ckUserKievRPSSecAuth.Value == "" {
if USER_KievRPSSecAuth != "" {
@@ -160,6 +172,12 @@ func NewSingleHostReverseProxy(target *url.URL) *httputil.ReverseProxy {
}
//改写返回信息
modifyFunc := func(res *http.Response) error {
+ cookies := res.Cookies()
+ res.Header.Set("Set-Cookie", "")
+ for _, cookie := range cookies {
+ values := strings.Split(cookie.String(), ";")
+ res.Header.Add("Set-Cookie", values[0]+"; "+values[1])
+ }
contentType := res.Header.Get("Content-Type")
if strings.Contains(contentType, "text/javascript") {
contentEncoding := res.Header.Get("Content-Encoding")
@@ -191,7 +209,7 @@ func NewSingleHostReverseProxy(target *url.URL) *httputil.ReverseProxy {
Value: resCKRandIndex,
Path: "/",
}
- res.Header.Set("Set-Cookie", ckRandIndex.String())
+ res.Header.Add("Set-Cookie", ckRandIndex.String())
}
// 删除 CSP
@@ -218,7 +236,7 @@ func NewSingleHostReverseProxy(target *url.URL) *httputil.ReverseProxy {
Value: randIP,
Path: "/",
}
- res.Header.Set("Set-Cookie", ckRandIP.String())
+ res.Header.Add("Set-Cookie", ckRandIP.String())
// 跨域
// if IS_DEBUG_MODE {
diff --git a/frontend/src/components/ChatNav/ChatNav.vue b/frontend/src/components/ChatNav/ChatNav.vue
index d9adf6392b..1560153a5d 100644
--- a/frontend/src/components/ChatNav/ChatNav.vue
+++ b/frontend/src/components/ChatNav/ChatNav.vue
@@ -17,6 +17,7 @@ const isShowSetAboutModal = ref(false);
const userToken = ref('');
const userKievRPSSecAuth = ref('');
const userRwBf = ref('');
+const userMUID = ref('');
const message = useMessage();
const promptStore = usePromptStore();
const { isShowPromptSotre } = storeToRefs(promptStore);
@@ -138,6 +139,7 @@ const handleSelect = (key: string) => {
userToken.value = userStore.getUserToken();
userKievRPSSecAuth.value = userStore.getUserKievRPSSecAuth();
userRwBf.value = userStore.getUserRwBf();
+ userMUID.value = userStore.getUserMUID();
history.value = historyEnable.value;
cookiesEnable.value = fullCookiesEnable.value;
if (cookiesEnable.value) { cookies.value = cookiesStr.value; }
@@ -195,6 +197,11 @@ const saveSetting = () => {
} else {
userStore.saveUserRwBf(userRwBf.value);
}
+ if (!userMUID.value) {
+ message.warning('请先填入用户 MUID Cookie');
+ } else {
+ userStore.saveUserMUID(userMUID.value);
+ }
}
fullCookiesEnable.value = cookiesEnable.value;
historyEnable.value = history.value;
@@ -257,6 +264,9 @@ const saveSetting = () => {
+
+
+
diff --git a/frontend/src/stores/modules/user/index.ts b/frontend/src/stores/modules/user/index.ts
index 6ac0293a89..da85c247e9 100644
--- a/frontend/src/stores/modules/user/index.ts
+++ b/frontend/src/stores/modules/user/index.ts
@@ -66,8 +66,10 @@ export const useUserStore = defineStore(
return userCookieVal;
};
- const checkUserToken = () => {
- cookies.set(userMUIDCookieName, '3AC75B6BED5B6C3B03384913EC756D93', 365 * 24 * 60, '/')
+ const checkUserToken = async () => {
+ await fetch('/search?q=Bing+AI&showconv=1&FORM=hpcodx&ajaxhist=0&ajaxserp=0&cc=us', {
+ credentials: 'include',
+ })
if (historyEnable.value) {
CIB.vm.sidePanel.isVisibleDesktop = true;
document.querySelector('cib-serp')?.setAttribute('alignment', 'left');
@@ -136,6 +138,15 @@ export const useUserStore = defineStore(
cookies.set(userRwBfCookieName, token, 7 * 24 * 60, '/');
};
+ const getUserMUID = () => {
+ const userCookieVal = cookies.get(userMUIDCookieName) || '';
+ return userCookieVal;
+ };
+
+ const saveUserMUID = (token: string) => {
+ cookies.set(userMUIDCookieName, token, 7 * 24 * 60, '/');
+ };
+
const resetCache = async () => {
const keys = document.cookie.split(";");
if (keys) {
@@ -169,6 +180,8 @@ export const useUserStore = defineStore(
saveUserKievRPSSecAuth,
getUserRwBf,
saveUserRwBf,
+ getUserMUID,
+ saveUserMUID,
saveCookies,
cookiesStr,
historyEnable,
diff --git a/frontend/src/views/chat/components/Chat/Chat.vue b/frontend/src/views/chat/components/Chat/Chat.vue
index 630de54f34..5e76f7555a 100644
--- a/frontend/src/views/chat/components/Chat/Chat.vue
+++ b/frontend/src/views/chat/components/Chat/Chat.vue
@@ -112,7 +112,7 @@ const initSysConfig = async () => {
isShowUnauthorizedModal.value = true;
return;
}
- afterAuth(res.data);
+ await afterAuth(res.data);
}
break;
default:
@@ -121,9 +121,9 @@ const initSysConfig = async () => {
}
};
-const afterAuth = (data: SysConfig) => {
+const afterAuth = async (data: SysConfig) => {
if (!data.isSysCK) {
- userStore.checkUserToken();
+ await userStore.checkUserToken();
}
initChatService();
};
@@ -143,6 +143,12 @@ const hackStyle = () => {
const conversationEle = serpEle?.shadowRoot?.querySelector('cib-conversation') as HTMLElement;
// todo 反馈暂时无法使用,先移除
const welcomeEle = conversationEle?.shadowRoot?.querySelector('cib-welcome-container');
+ const loginTip = welcomeEle?.shadowRoot?.querySelectorAll("div[class='muid-upsell']");
+ if (loginTip?.length) {
+ loginTip.forEach((ele) => {
+ ele.remove();
+ });
+ }
welcomeEle?.shadowRoot?.querySelector('.preview-container')?.remove();
serpEle?.shadowRoot?.querySelector('cib-serp-feedback')?.remove();
if (isMobile()) {