Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions frontend/src/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const BASE = import.meta.env.VITE_API_URL || 'http://localhost:3000';

export async function api(path, options = {}) {
const res = await fetch(`${BASE}/api/v1${path}`, {
const res = await fetch(`/api/v1${path}`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/lib/sse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const BASE = import.meta.env.VITE_API_URL || 'http://localhost:3000';

export function openEventStream(handlers) {
const url = `${BASE}/api/v1/events`;
const url = `/api/v1/events`;
const source = new EventSource(url, { withCredentials: true });

for (const [event, handler] of Object.entries(handlers)) {
Expand Down
20 changes: 16 additions & 4 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
server: { port: 5173 },
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');

return {
plugins: [react()],
server: {
port: 5173,
proxy: {
'/api': {
target: env.VITE_API_URL || 'http://localhost:3000',
changeOrigin: true,
},
},
},
};
});