diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index acfb4ca..ab5758e 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -3,6 +3,21 @@ import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import path from 'path' +// Forward browser's original Host to the backend so API docs URLs match +function forwardHost() { + return { + configure: (proxy: any) => { + proxy.on('proxyReq', (proxyReq: any, req: any) => { + const host = req.headers.host; + if (host) { + proxyReq.setHeader('X-Forwarded-Host', host); + proxyReq.setHeader('X-Forwarded-Proto', 'http'); + } + }); + }, + }; +} + export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { @@ -12,10 +27,10 @@ export default defineConfig({ }, server: { proxy: { - '/api': 'http://localhost:8000', - '/docs': 'http://localhost:8000', - '/redoc': 'http://localhost:8000', - '/openapi.json': 'http://localhost:8000', + '/api': { target: 'http://localhost:8000', ...forwardHost() }, + '/docs': { target: 'http://localhost:8000', ...forwardHost() }, + '/redoc': { target: 'http://localhost:8000', ...forwardHost() }, + '/openapi.json': { target: 'http://localhost:8000', ...forwardHost() }, }, }, })