Get api url from env

dev
Platon Yasev 3 years ago
parent 54bc1604a8
commit c5282532fb

@ -0,0 +1 @@
VITE_API_URL=https://postnet.dev.selftech.ru

@ -0,0 +1 @@
VITE_API_URL=https://postnet.dev.selftech.ru

@ -4,13 +4,13 @@ import { STATUSES } from "./config";
import { usePointSelection } from "./stores/usePointSelection"; import { usePointSelection } from "./stores/usePointSelection";
import { usePendingPointsFilters } from "./stores/usePendingPointsFilters"; import { usePendingPointsFilters } from "./stores/usePendingPointsFilters";
export const BASE_URL = "https://postnet-dev.selftech.ru"; export const BASE_URL = import.meta.env.VITE_API_URL;
export const api = axios.create({ export const api = axios.create({
baseURL: baseURL:
import.meta.env.MODE === "development" import.meta.env.MODE === "development"
? "http://localhost:5173/" ? "http://localhost:5173/"
: `${BASE_URL}/`, : BASE_URL,
withCredentials: true, withCredentials: true,
xsrfHeaderName: "X-CSRFToken", xsrfHeaderName: "X-CSRFToken",
xsrfCookieName: "csrftoken", xsrfCookieName: "csrftoken",

@ -1,28 +1,30 @@
import { defineConfig } from "vite"; import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr"; import svgr from "vite-plugin-svgr";
const BASE_URL = "https://postnet-dev.selftech.ru/"; export default defineConfig(({ mode }) => {
// @ts-ignore
const env = loadEnv(mode, process.cwd());
// https://vitejs.dev/config/ return {
export default defineConfig({ base: "/",
base: "/", plugins: [svgr(), react()],
plugins: [svgr(), react()], server: {
server: { proxy: {
proxy: { "/account": env.VITE_API_URL,
"/account": BASE_URL, "/api": env.VITE_API_URL,
"/api": BASE_URL, },
}, },
}, css: {
css: { preprocessorOptions: {
preprocessorOptions: { less: {
less: { modifyVars: {
modifyVars: { "primary-color": "#CC2222FF",
"primary-color": "#CC2222FF", "border-radius-base": "5px",
"border-radius-base": "5px", },
javascriptEnabled: true,
}, },
javascriptEnabled: true,
}, },
}, },
}, };
}); });

Loading…
Cancel
Save