Search posts, tags, users, and pages
Using environment variables when working with reactjs template inside Vite
Ramadevsign (Rama Ochieng)
@RamaSpeaksDevsign · EMEA (GMT - GMT+3)
Devsigner(Developer & Designer) | Open Source Contributor
I am a Designer and Front End developer creating beautiful experiences online
Markdown supported · ⌘↵ to post
Ashutosh Jha
How can I add Environment Variables in Vite React Project in the vite.config.js file
import { defineConfig } from "vite"; import react from "@vitejs/plugin-react";
const proxy_url = "localhost/";
export default defineConfig({ plugins: [react()], server: { proxy: { "/api": { target: proxy_url, changeOrigin: true, rewrite: (path) => path.replace(/^/api/, ""), }, }, }, });
Ogochukwu Azubogu
This was a huge help. Thanks.✨
Ashutosh Jha
How can I add Environment Variables in Vite React Project in the vite.config.js file
import { defineConfig } from "vite"; import react from "@vitejs/plugin-react";
const proxy_url = "localhost/";
export default defineConfig({ plugins: [react()], server: { proxy: { "/api": { target: proxy_url, changeOrigin: true, rewrite: (path) => path.replace(/^/api/, ""), }, }, }, });