upload zip archive from strava

This commit is contained in:
Davide Scaini
2026-04-10 22:26:11 +02:00
parent fc6c00c6eb
commit da622131fd
4 changed files with 77 additions and 1 deletions
+21
View File
@@ -25,6 +25,27 @@ export default defineConfig({
// In production nginx handles this — same pattern, no code change needed.
server: {
proxy: {
// SSE response to a POST — Vite's default proxy buffers the full body before
// forwarding, which breaks streaming and can cause EPIPE on long uploads.
// selfHandleResponse + manual pipe sends chunks as they arrive.
'/api/upload/strava-zip': {
target: serveTarget,
changeOrigin: true,
selfHandleResponse: true,
configure: (proxy) => {
proxy.on('proxyRes', (proxyRes, req, res) => {
res.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);
proxyRes.pipe(res, { end: true });
});
proxy.on('error', (err, _req, res) => {
if (err.code === 'EPIPE' || err.code === 'ECONNRESET') return;
if (!res.headersSent) {
res.writeHead(502);
res.end('proxy error');
}
});
},
},
'/api': {
target: serveTarget,
changeOrigin: true,