test(ws): testing ws connection on the frontend

This commit is contained in:
2025-08-01 15:54:52 -05:00
parent c775bb3354
commit 486e4fb6b8
2 changed files with 28 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ const WebSocketViewer = () => {
ws.current = new WebSocket(
(window.location.protocol === "https:" ? "wss://" : "ws://") +
window.location.host +
"/lst/api/logger/logs"
"/lst/ws"
);
ws.current.onopen = () => {

View File

@@ -1,6 +1,13 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import dotenv from "dotenv";
import { fileURLToPath } from "url";
dotenv.config({
path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.env"),
});
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
@@ -10,4 +17,24 @@ export default defineConfig({
assetsDir: "assets",
emptyOutDir: true,
},
server: {
proxy: {
"/lst/api": {
target: `http://localhost:${Number(
process.env.VITE_SERVER_PORT || 8080
)}`,
changeOrigin: true,
secure: false,
},
"/lst/ws": {
target: `ws://localhost:${Number(
process.env.VITE_SERVER_PORT || 8080
)}`, // Your Go WebSocket endpoint
ws: true,
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/ws/, ""),
},
},
},
});