Skip to content

Commit

Permalink
Add flags for API.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hmallen99 committed Feb 12, 2025
1 parent 4db1c12 commit ec21fc0
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions packages/client-core/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { API as CommonAPI } from '@ir-engine/common'
import type { ServiceTypes } from '@ir-engine/common/declarations'
import config from '@ir-engine/common/src/config'

import { HyperFlux } from '@ir-engine/hyperflux'
import { isReactNative } from '@ir-engine/spatial/src/common/functions/isMobile'
import primusClient from './util/primus-client'

declare module '@feathersjs/client' {
Expand All @@ -48,19 +50,32 @@ export class API {
static instance: API
client: FeathersApplication<ServiceTypes>

static createAPI = (pathName: string = window?.location?.pathname || 'default') => {
static createAPI = () => {
const feathersClient = feathers()

const primus = new Primus(`${config.client.serverUrl}?pathName=${window.location.pathname}`, {
const query = {
pathName: window.location.pathname,
peerID: HyperFlux.store.peerID
}

const queryString = new URLSearchParams(query).toString()

const uri = isReactNative
? `${config.client.serverUrl}?pathName=${window.location.pathname}`
: `${config.client.serverUrl}?${queryString}`

const primus = new Primus(uri, {
withCredentials: true,
pingTimeout: config.websocket.pingTimeout,
pingInterval: config.websocket.pingInterval,
transport: {
headers: {
Origin: config.client.clientUrl,
Host: process.env.VITE_SERVER_HOST
}
}
transport: isReactNative
? {
headers: {
Origin: config.client.clientUrl,
Host: process.env.VITE_SERVER_HOST
}
}
: undefined
})
feathersClient.configure(primusClient(primus, { timeout: 10000 }))

Expand Down

0 comments on commit ec21fc0

Please sign in to comment.