Skip to content

Commit a03431c

Browse files
committed
Update api.ts
1 parent 6184e81 commit a03431c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/api.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ import { CatClient, type CancelablePromise } from 'ccat-api'
44

55
const { DEV } = import.meta.env
66

7+
const getPort = () => {
8+
if (DEV) return 1865
9+
if (window.location.port == '443' || window.location.port == '80') return undefined
10+
return parseInt(window.location.port)
11+
}
12+
713
/**
814
* API client to make requests to the endpoints and passing the API_KEY for authentication.
915
*/
1016
export const apiClient = new CatClient({
1117
baseUrl: window.location.hostname,
12-
port: parseInt((DEV ? '1865' : window.location.port) ?? '80'),
18+
port: getPort(),
1319
secure: window.location.protocol === 'https:',
1420
timeout: 15000,
1521
ws: {

0 commit comments

Comments
 (0)