Skip to content

Commit

Permalink
*req_url
Browse files Browse the repository at this point in the history
  • Loading branch information
chengxs1994 committed Jun 27, 2023
1 parent d9d36dd commit 16c0141
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
CODE?: string;
BASE_URL?: string;
PROXY_URL?: string;
REQ_URL?: string;
VERCEL?: string;
HIDE_USER_API_KEY?: string; // disable user's api key input
DISABLE_GPT4?: string; // allow user to use gpt-4 or not
Expand Down Expand Up @@ -34,6 +35,8 @@ export const getServerSideConfig = () => {
);
}

console.log("process.env", process.env);

return {
apiKey: process.env.OPENAI_API_KEY,
code: process.env.CODE,
Expand Down
12 changes: 9 additions & 3 deletions app/requests.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { getItem } from "./locales";
import { getServerSideConfig } from "@/app/config/server";

const serverConfig = getServerSideConfig();
const USER_HOST = serverConfig.reqUrl;

export async function accountReLogin(
inputAccountValue: string,
inputPasswordValue: string,
Expand All @@ -12,6 +9,9 @@ export async function accountReLogin(
formData.append("account", inputAccountValue);
formData.append("password", inputPasswordValue);

var serverConfig = getServerSideConfig();
var USER_HOST = serverConfig.reqUrl;

return fetch(USER_HOST + `/api/account-relogin`, {
method: "POST",
body: formData,
Expand All @@ -27,6 +27,9 @@ export async function userInfo() {
}
formData.append("token", userKey);

var serverConfig = getServerSideConfig();
var USER_HOST = serverConfig.reqUrl;

return fetch(USER_HOST + `/api/user-info`, {
method: "POST",
body: formData,
Expand All @@ -43,6 +46,9 @@ export async function send(content: string) {
formData.append("token", userKey);

formData.append("message", content);

var serverConfig = getServerSideConfig();
var USER_HOST = serverConfig.reqUrl;
return fetch(USER_HOST + `/api/send`, {
method: "POST",
body: formData,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- OPENAI_API_KEY=$OPENAI_API_KEY
- CODE=$CODE
- PROXY_URL=$PROXY_URL
- REQ_URL=REQ_URL
- BASE_URL=$BASE_URL
- OPENAI_ORG_ID=$OPENAI_ORG_ID
- HIDE_USER_API_KEY=$HIDE_USER_API_KEY
Expand Down

0 comments on commit 16c0141

Please sign in to comment.