From a03431c376717ef2ca7011838cd1a68879456505 Mon Sep 17 00:00:00 2001 From: Dany Date: Thu, 4 Jan 2024 16:42:01 +0100 Subject: [PATCH] Update api.ts --- src/api.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index ead928f..c276767 100644 --- a/src/api.ts +++ b/src/api.ts @@ -4,12 +4,18 @@ import { CatClient, type CancelablePromise } from 'ccat-api' const { DEV } = import.meta.env +const getPort = () => { + if (DEV) return 1865 + if (window.location.port == '443' || window.location.port == '80') return undefined + return parseInt(window.location.port) +} + /** * API client to make requests to the endpoints and passing the API_KEY for authentication. */ export const apiClient = new CatClient({ baseUrl: window.location.hostname, - port: parseInt((DEV ? '1865' : window.location.port) ?? '80'), + port: getPort(), secure: window.location.protocol === 'https:', timeout: 15000, ws: {