diff --git a/server/src/index.ts b/server/src/index.ts index 3012065..a708e7c 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -44,12 +44,6 @@ app.register(FastifyWS); let tts = null; -app.register(FastifyStatic, { - root: path.dirname(fileURLToPath(import.meta.url)) + "/../../webapp/dist/", - prefix: "/", - decorateReply: true - }); - if (config.tts.enabled) { tts = new TTSClient(config.tts); app.register(FastifyStatic, { @@ -75,7 +69,7 @@ for (let agent of config.agents) { app.register(FastifyStatic, { root: path.resolve(config.chat.agentsDir), prefix: "/api/agents/", - decorateReply: false, + decorateReply: true, }); app.get("/api/agents", (req, res) => { diff --git a/webapp/config.ts b/webapp/config.ts new file mode 100644 index 0000000..bd75dce --- /dev/null +++ b/webapp/config.ts @@ -0,0 +1,4 @@ +export const Config = { + // The server address for the webapp to connect to. The below default is the same address the webapp is hosted at. + serverAddress: `${window.location.protocol}//${window.location.host}` +} \ No newline at end of file diff --git a/webapp/src/ts/main.ts b/webapp/src/ts/main.ts index 67c8001..63b4183 100644 --- a/webapp/src/ts/main.ts +++ b/webapp/src/ts/main.ts @@ -1,6 +1,7 @@ import { MSWindow, MSWindowStartPosition } from "./MSWindow.js"; import { agentInit } from "@msagent-chat/msagent.js"; import { MSAgentClient } from "./client.js"; +import { Config } from "../../config.js"; const elements = { @@ -23,7 +24,7 @@ const elements = { let Room : MSAgentClient; function roomInit() { - Room = new MSAgentClient(`${window.location.protocol}//${window.location.host}`, elements.chatView); + Room = new MSAgentClient(Config.serverAddress, elements.chatView); Room.on('close', () => { for (let user of Room.getUsers()) { user.agent.remove();