refactor: Migrate to API endpoint and use real DB connection
This commit shifts the application's data fetching mechanism from local storage mocks to a dedicated API endpoint. It also refactors the database connection logic to utilize a connection pool for improved performance and scalability. Key changes include: - Disabling `FORCE_LOCAL_DB` in `mockDb.ts` and implementing a generic `request` function for API calls. - Centralizing authentication headers in `mockDb.ts`. - Modifying `server/db.js` to use `pg` and `mysql2/promise` pools and a unified `executeQuery` function. - Updating `server/server.js` to use the database pool for queries. - Configuring Vite's development server to proxy API requests to the backend.
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:3001',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user