@@ -8,6 +8,7 @@ export interface InitialParams {
88 accessToken ?: string ;
99 customApiHost ?: string ;
1010 customWebSocketHost ?: string ;
11+ region ?: string ;
1112}
1213
1314interface ParamsAsProps {
@@ -18,18 +19,24 @@ interface ParamsAsProps {
1819 allowProfileEdit : boolean ;
1920 isMultipleFilesMessageEnabled : boolean ;
2021 uikitOptions : UIKitOptions ;
22+ customApiHost ?: string ;
23+ customWebSocketHost ?: string ;
2124}
2225
2326export const useConfigParams = ( initParams : InitialParams ) : ParamsAsProps => {
2427 const [ searchParams ] = useSearchParams ( ) ;
2528
29+ const { customApiHost = searchParams . get ( 'customApiHost' ) , customWebSocketHost = searchParams . get ( 'customWebSocketHost' ) } = getHostBy (
30+ searchParams . get ( 'region' ) ,
31+ ) ;
32+
2633 const response = {
2734 appId : searchParams . get ( 'appId' ) || initParams . appId ,
2835 userId : searchParams . get ( 'userId' ) || initParams . userId ,
2936 nickname : searchParams . get ( 'nickname' ) || initParams . nickname || initParams . userId ,
3037 accessToken : searchParams . get ( 'accessToken' ) || initParams . accessToken ,
31- customApiHost : searchParams . get ( 'customApiHost' ) || initParams . customApiHost ,
32- customWebSocketHost : searchParams . get ( 'customWebSocketHost' ) || initParams . customWebSocketHost ,
38+ customApiHost,
39+ customWebSocketHost,
3340 allowProfileEdit : parseValue ( searchParams . get ( 'enableProfileEdit' ) ) ?? true ,
3441 isMultipleFilesMessageEnabled : parseValue ( searchParams . get ( 'enableMultipleFilesMessage' ) ) ?? true ,
3542 enableLegacyChannelModules : parseValue ( searchParams . get ( 'enableLegacyChannelModules' ) ) ?? false ,
@@ -70,6 +77,17 @@ export const useConfigParams = (initParams: InitialParams): ParamsAsProps => {
7077 return response ;
7178} ;
7279
80+ function getHostBy ( region ?: string | null ) {
81+ if ( region ?. startsWith ( 'no' ) ) {
82+ return {
83+ customApiHost : `https://api-${ region } .sendbirdtest.com` ,
84+ customWebSocketHost : `wss://ws-${ region } .sendbirdtest.com` ,
85+ } ;
86+ }
87+
88+ return { customApiHost : undefined , customWebSocketHost : undefined } ;
89+ }
90+
7391function parseValue ( value ?: string | null ) {
7492 if ( ! value ) return value ;
7593 if ( value . toLowerCase ( ) . match ( / t r u e / ) ) {
0 commit comments