From 478bb446c3fd9ee6077c7abad6698a583e075e5b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 6 Jun 2023 10:06:14 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(frontend):=20add=20missing?= =?UTF-8?q?=20api/v1=20prefix=20to=20API=20routes=20=F0=9F=90=9B=20fix(fro?= =?UTF-8?q?ntend):=20add=20missing=20api/v1=20prefix=20to=20WebSocket=20UR?= =?UTF-8?q?L=20=F0=9F=90=9B=20fix(frontend):=20add=20missing=20api/v1=20pr?= =?UTF-8?q?efix=20to=20Vite=20proxy=20target=20The=20API=20routes,=20WebSo?= =?UTF-8?q?cket=20URL,=20and=20Vite=20proxy=20target=20were=20missing=20th?= =?UTF-8?q?e=20"api/v1"=20prefix,=20causing=20the=20frontend=20to=20not=20?= =?UTF-8?q?be=20able=20to=20communicate=20with=20the=20backend.=20This=20c?= =?UTF-8?q?ommit=20adds=20the=20missing=20prefix=20to=20all=20three=20loca?= =?UTF-8?q?tions=20to=20fix=20the=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/controllers/API/index.ts | 4 ++-- src/frontend/src/modals/chatModal/index.tsx | 4 ++-- src/frontend/vite.config.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index f6f46404b..0cffd04bf 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -14,13 +14,13 @@ export async function sendAll(data: sendAllProps) { export async function checkCode( code: string ): Promise> { - return await axios.post("/validate/code", { code }); + return await axios.post("api/v1/validate/code", { code }); } export async function checkPrompt( template: string ): Promise> { - return await axios.post("/validate/prompt", { template }); + return await axios.post("api/v1/validate/prompt", { template }); } export async function getExamples(): Promise { diff --git a/src/frontend/src/modals/chatModal/index.tsx b/src/frontend/src/modals/chatModal/index.tsx index cf2b52aac..39bb72994 100644 --- a/src/frontend/src/modals/chatModal/index.tsx +++ b/src/frontend/src/modals/chatModal/index.tsx @@ -182,10 +182,10 @@ export default function ChatModal({ try { const urlWs = process.env.NODE_ENV === "development" - ? `ws://localhost:7860/chat/${id.current}` + ? `ws://localhost:7860/api/v1/chat/${id.current}` : `${window.location.protocol === "https:" ? "wss" : "ws"}://${ window.location.host - }/chat/${id.current}`; + }api/v1/chat/${id.current}`; const newWs = new WebSocket(urlWs); newWs.onopen = () => { console.log("WebSocket connection established!"); diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index 172b37733..d4fa2248b 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -11,7 +11,7 @@ const apiRoutes = [ ]; // Use environment variable to determine the target. -const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860"; +const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860/api/v1"; const proxyTargets = apiRoutes.reduce((proxyObj, route) => { proxyObj[route] = {