From 6032e3533fa01cb722d750db13419406da344ae0 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Wed, 1 Jul 2026 15:30:09 +0530 Subject: React sample apps: useEffect hook, Axios api calls --- react/06-api-calls/vite.config.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 react/06-api-calls/vite.config.js (limited to 'react/06-api-calls/vite.config.js') diff --git a/react/06-api-calls/vite.config.js b/react/06-api-calls/vite.config.js new file mode 100644 index 0000000..f0b256a --- /dev/null +++ b/react/06-api-calls/vite.config.js @@ -0,0 +1,23 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], + + // Forward requests to /bff/api to another server (like json-server) + server: { + proxy: { + '/bff/api': { + target: 'http://localhost:3000', + + changeOrigin: true, // Rewrites the host header to match the target + + secure: false, // Allows self-signed SSL certificates for HTTPS targets + + // Strips out '/bff/api' before passing the request to the target server + rewrite: (path) => path.replace(/^\/bff\/api/, ''), + } + } + } +}) -- cgit v1.2.3