test(ws): testing ws connection on the frontend
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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/, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user