Skip to content

Commit

Permalink
Update api.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Jan 4, 2024
1 parent 6184e81 commit a03431c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit a03431c

Please sign in to comment.