mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-26 10:39:21 +08:00
feat: encode access-code in header for better safety
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ChatRequest, ChatReponse } from "./api/openai/typing";
|
||||
import { Message, ModelConfig, useAccessStore, useChatStore } from "./store";
|
||||
import { showToast } from "./components/ui-lib";
|
||||
import md5 from "spark-md5";
|
||||
|
||||
const TIME_OUT_MS = 30000;
|
||||
|
||||
@@ -37,8 +38,8 @@ function getHeaders() {
|
||||
const accessStore = useAccessStore.getState();
|
||||
let headers: Record<string, string> = {};
|
||||
|
||||
if (accessStore.enabledAccessControl()) {
|
||||
headers["access-code"] = accessStore.accessCode;
|
||||
if (accessStore.enabledAccessControl() && accessStore.accessCode.length) {
|
||||
headers["access-code"] = md5.hash(accessStore.accessCode);
|
||||
}
|
||||
|
||||
if (accessStore.token && accessStore.token.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user