T
TanStack•5mo ago
frail-apricot

how to proxy requests to backend only in dev?

anyone know if there is a way that I could proxy /api requests ONLY in dev looking to proxy something like /api/v1/auth/**/* to a different URL only in dev, as in prod will just be same domain 🙂
2 Replies
ratty-blush
ratty-blush•2mo ago
try to change your vite.config.ts and add the server options like this import tailwindcss from "@tailwindcss/vite"; import { tanstackStart } from "@tanstack/react-start/plugin/vite"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; // https://vite.dev/config/ export default defineConfig({ plugins: [ tsconfigPaths(), tanstackStart({ target: "bun", customViteReactPlugin: true, }), react(), tailwindcss(), ], server: { proxy: { "/api": "http://localhost:8000", }, }, });
vitejs
Configuring Vite
Next Generation Frontend Tooling
ratty-blush
ratty-blush•2mo ago

Did you find this page helpful?