upload zip archive from strava
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user