chore: replace hardcoded WebSocket URL with environment variable

- Replaced the hardcoded LSP WebSocket URL with a configurable environment variable (NEXT_PUBLIC_LSP_C_URL).
- Default to "ws://localhost:4594/clangd" if the environment variable is not set.
This commit is contained in:
cfngc4594 2025-02-20 08:44:11 +08:00
parent 6c5beeb27c
commit 3f2bc8c332

View File

@ -27,7 +27,8 @@ export default function CodeEditor() {
const { resolvedTheme } = useTheme(); const { resolvedTheme } = useTheme();
useEffect(() => { useEffect(() => {
const url = normalizeUrl("ws://localhost:4594/clangd"); const lspUrl = process.env.NEXT_PUBLIC_LSP_C_URL || "ws://localhost:4594/clangd";
const url = normalizeUrl(lspUrl);
const webSocket = new WebSocket(url); const webSocket = new WebSocket(url);
webSocket.onopen = async () => { webSocket.onopen = async () => {