🐛 fix(vite.config.ts): remove /api/v1 prefix from proxy target URL

 feat(vite.config.ts): add rewrite function to proxy configuration to add /api/v1 prefix to requests
The /api/v1 prefix was removed from the proxy target URL as it was already being added by the rewrite function. The rewrite function was added to the proxy configuration to add the /api/v1 prefix to requests, which is required by the backend API.

Fixes #458
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-09 14:31:09 -03:00
commit 51ecc05563

View file

@ -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/api/v1";
const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860";
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
proxyObj[route] = {
@ -19,6 +19,7 @@ const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
changeOrigin: true,
secure: false,
ws: true,
rewrite: (path) => `/api/v1${path}`,
};
return proxyObj;
}, {});