From 7096fbed868e382aa2ee75bc023c25b65b1318e8 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Fri, 20 Nov 2020 18:37:22 +0100 Subject: [PATCH] Better url handling when connecting to socketio. --- src/components/VirtualLotteryPage.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/VirtualLotteryPage.vue b/src/components/VirtualLotteryPage.vue index a32e3df..1cca3bc 100644 --- a/src/components/VirtualLotteryPage.vue +++ b/src/components/VirtualLotteryPage.vue @@ -87,13 +87,15 @@ export default { }; }, created() { - getChatHistory(0, 100).then(messages => (this.chatHistory = messages)); + getChatHistory(0, this.historyPageSize) + .then(messages => this.chatHistory = messages); }, mounted() { this.track(); this.getAttendees(); this.getWinners(); - this.socket = io(`${window.location.hostname}:${window.location.port}`); + const BASE_URL = __APIURL__ || window.location.origin; + this.socket = io(`${BASE_URL}`); this.socket.on("color_winner", msg => {}); this.socket.on("chat", msg => { @@ -167,10 +169,11 @@ export default { const { historyPage, historyPageSize } = this; const page = historyPage + 1; - getChatHistory(page * historyPageSize, historyPageSize).then(messages => { - this.chatHistory = messages.concat(this.chatHistory); - this.historyPage = page; - }); + getChatHistory(page * historyPageSize, historyPageSize) + .then(messages => { + this.chatHistory = messages.concat(this.chatHistory); + this.historyPage = page; + }); }, getWinners: async function() { let response = await winners();