Skip to content

Commit

Permalink
🚀 proxy bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Salah Eddine Lalami committed Oct 30, 2023
1 parent a1625bf commit 3c5bfcc
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 155 deletions.
3 changes: 2 additions & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# to connect your frontend to remote backend server
VITE_BACKEND_SERVER="http://your_backend_url_server.com/"
VITE_BACKEND_SERVER="http://your_backend_url_server.com/"
PROD = false
123 changes: 10 additions & 113 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"cross-env": "7.0.3",
"currency.js": "2.0.4",
"history": "4.10.1",
"http-proxy-middleware": "^2.0.6",
"just-compare": "^2.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
92 changes: 52 additions & 40 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,60 @@
import path from 'path';

// import { defineConfig, loadEnv } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
// export default ({ mode }) => {
// process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
// const config = {
// plugins: [react()],
// resolve: {
// base: '/',
// alias: {
// '@': path.resolve(__dirname, 'src'),
// },
// },
// server: {
// proxy: {
// '/api': {
// target: 'http://dev-server.idurarapp.com/',
// changeOrigin: false,
// secure: false,
// },
// },
// },
// };
// return defineConfig(config);
// };
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
base: '/',
alias: {
'@': path.resolve(__dirname, 'src'),
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const config = {
plugins: [react()],
resolve: {
base: '/',
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
},
server: {
proxy: {
'/api': {
target: 'http://dev-server.idurarapp.com/',
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, ''),
server: {
proxy: {
'/api': {
target: process.env.VITE_BACKEND_SERVER,
changeOrigin: true,
secure: false,
},
},
},
},
});
};
return defineConfig(config);
};
// https://vitejs.dev/config/

// export default defineConfig(({ command, mode }) => {
// // Load env file based on `mode` in the current working directory.
// // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
// const env = loadEnv(mode, process.cwd(), '');
// return {
// // vite config
// define: {
// __APP_ENV__: JSON.stringify(env.APP_ENV),
// },
// };
// });

// export default defineConfig({
// plugins: [react()],
// resolve: {
// base: '/',
// alias: {
// '@': path.resolve(__dirname, 'src'),
// },
// },
// server: {
// proxy: {
// '/api': {
// target: import.meta.env.VITE_BACKEND_SERVER,
// changeOrigin: true,
// secure: false,
// },
// },
// },
// });

0 comments on commit 3c5bfcc

Please sign in to comment.