@cloudbase/app 2.21.1 → 2.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -140,7 +140,7 @@ class Cloudbase implements ICloudbase {
140
140
  setGatewayEndPointWithEnv(env)
141
141
 
142
142
  const app = new Cloudbase(this.cloudbaseConfig)
143
- initRequest({ env, region: config.region || '', timeout, oauthClient, _fromApp: app, i18n })
143
+ initRequest({ env, region: config.region || '', timeout, oauthClient, _fromApp: app, i18n, endPointMode: config.endPointMode })
144
144
  app.requestClient = this.requestClient
145
145
  ;(this as any)?.fire?.('cloudbase_init', app)
146
146
  this.try2InitAuth(config, app)
@@ -243,13 +243,22 @@ export class CloudbaseRequest implements ICloudbaseRequest {
243
243
  ...formatQuery,
244
244
  })
245
245
 
246
- const { baseUrl: BASE_URL, protocol: PROTOCOL } = getEndPointInfo(this.config.env, 'CLOUD_API')
246
+ const endPointMode = this.config.endPointMode || 'CLOUD_API'
247
+
248
+ const url = getEndPointInfo(this.config.env, endPointMode)
249
+ let BASE_URL = url.baseUrl
250
+ const PROTOCOL = url.protocol
251
+
252
+ if (action === 'functions.invokeFunction' && endPointMode === 'GATEWAY') {
253
+ BASE_URL = `${BASE_URL.match(/\/\/([^/?#]*)/)[0]}/web`
254
+ }
255
+
247
256
  // 生成请求 url
248
257
  let newUrl
249
258
  if (options.pathname) {
250
259
  newUrl = formatUrl(
251
260
  PROTOCOL,
252
- `${getBaseEndPoint(this.config.env)?.replace(/^https?:/, '')}/${options.pathname}`,
261
+ `${getBaseEndPoint(this.config.env, endPointMode)?.replace(/^https?:/, '')}/${options.pathname}`,
253
262
  formatQuery,
254
263
  )
255
264
  } else {