基于txt/event-stream
的EventSource流,使用代理时需注意:
开发阶段如果使用vue自带的代理,需要关闭compress,即
devServer: {
proxy: {
'/xx': {
target: ip,
changeOrigin: true,
pathRewrite: {
'^/xx': '/xx'
}
},
},
compress: false
}
再nginx部署则需要在location配置:
add_header Cache-Control no-cache;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
否则数据不会一点点的给出,而是一次性给出,达不到使用EventSource的效果。