feat: Configure Vite proxy for API requests and update API URL to use a relative path.
This commit is contained in:
parent
ff89fd1e87
commit
52e24c7f17
|
|
@ -1,6 +1,8 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const API_URL = 'http://localhost:8000';
|
// Use relative path '/api' which works with Nginx proxy in Docker
|
||||||
|
// and Vite proxy in local development
|
||||||
|
const API_URL = '/api';
|
||||||
|
|
||||||
export const generateCase = async (size, minVal, maxVal) => {
|
export const generateCase = async (size, minVal, maxVal) => {
|
||||||
const response = await axios.post(`${API_URL}/max_subarray/generate`, {
|
const response = await axios.post(`${API_URL}/max_subarray/generate`, {
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,13 @@ import react from '@vitejs/plugin-react'
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:8000',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue