From 6423a04fe4862ca058c10275ba86019f8963f60c Mon Sep 17 00:00:00 2001 From: Serkan Calis Date: Tue, 17 Sep 2024 16:25:55 +0300 Subject: [PATCH] fix baseUrl --- frontend/src/services/anecdotes.js | 2 +- frontend/vite.config.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/services/anecdotes.js b/frontend/src/services/anecdotes.js index a3a7c4c..395396f 100644 --- a/frontend/src/services/anecdotes.js +++ b/frontend/src/services/anecdotes.js @@ -1,6 +1,6 @@ import axios from 'axios'; -const baseUrl = 'http://localhost:3000/api/anecdotes'; +const baseUrl = '/api/anecdotes'; export async function getAll() { const response = await axios.get(baseUrl); diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 58f1945..8bc49c8 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,6 +4,14 @@ import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + server: { + proxy: { + '/api': { + target: 'http://localhost:3000', + changeOrigin: true, + }, + }, + }, test: { environment: 'jsdom', globals: true,