From 17cc2a475dceff574ee618c0445a7043e37ce04a Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Sat, 18 Jun 2022 01:14:31 +0200 Subject: [PATCH] Rename websocket from ws to livedata Allows devServer to proxy websockets as well... --- src/WebApi.cpp | 2 +- webapp/src/components/HomeView.vue | 2 +- webapp/vue.config.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/WebApi.cpp b/src/WebApi.cpp index 2715e2a..b9d4d19 100644 --- a/src/WebApi.cpp +++ b/src/WebApi.cpp @@ -5,7 +5,7 @@ WebApiClass::WebApiClass() : _server(HTTP_PORT) - , _ws("/ws") + , _ws("/livedata") , _events("/events") { } diff --git a/webapp/src/components/HomeView.vue b/webapp/src/components/HomeView.vue index 152b9eb..65cbf4f 100644 --- a/webapp/src/components/HomeView.vue +++ b/webapp/src/components/HomeView.vue @@ -90,7 +90,7 @@ export default { window.location.protocol === "https:" ? "wss:" : "ws:"; const port = window.location.port; const host = window.location.hostname; - const webSocketUrl = socketProtocol + "//" + host + ":" + port + "/ws"; + const webSocketUrl = socketProtocol + "//" + host + ":" + port + "/livedata"; this.connection = new WebSocket(webSocketUrl); diff --git a/webapp/vue.config.js b/webapp/vue.config.js index 02108b6..1538d2a 100644 --- a/webapp/vue.config.js +++ b/webapp/vue.config.js @@ -24,6 +24,15 @@ module.exports = defineConfig({ } }, devServer: { - proxy: 'http://192.168.20.110/' + proxy: { + '^/api': { + target: 'http://192.168.20.110/' + }, + '^/livedata': { + target: 'ws://192.168.20.110/', + ws: true, + changeOrigin: true + } + } } }) \ No newline at end of file