diff --git a/packages/board/package.json b/packages/board/package.json index 21d604b52..cf25fbdee 100644 --- a/packages/board/package.json +++ b/packages/board/package.json @@ -12,7 +12,7 @@ "dependencies": { "@botpress/webchat": "0.0.1", "@botpress/webchat-skin": "0.0.1", - "@botpress/messaging-client": "0.0.4", + "@botpress/messaging-client": "", "axios": "^0.21.1" } } diff --git a/packages/client/package.json b/packages/client/package.json index 919256308..92436ec9b 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@botpress/messaging-client", - "version": "0.0.4", + "version": "0.0.5", "main": "dist/index.js", "types": "dist/index.d.ts", "source": "src/index.ts", @@ -15,7 +15,7 @@ ], "devDependencies": {}, "dependencies": { - "axios": "^0.21.1", - "@botpress/messaging-base": "0.0.1" + "@botpress/messaging-base": "0.0.1", + "axios": "^0.21.1" } } diff --git a/packages/client/src/messaging.ts b/packages/client/src/messaging.ts index 6f64446ff..7e88ea294 100644 --- a/packages/client/src/messaging.ts +++ b/packages/client/src/messaging.ts @@ -35,13 +35,16 @@ export class MessagingClient { public authenticate(clientId: string, clientToken: string) { this.auth = { clientId, clientToken } - this.authHttp.defaults.headers['x-bp-messaging-client-id'] = clientId - this.authHttp.defaults.headers['x-bp-messaging-client-token'] = clientToken + this.authHttp.defaults.headers.common['x-bp-messaging-client-id'] = clientId + this.authHttp.defaults.headers.common['x-bp-messaging-client-token'] = clientToken } private configureHttpClient(client: AxiosInstance | undefined, config: AxiosRequestConfig) { if (client) { - client.defaults = { ...client.defaults, ...config } + client.interceptors.request.use((value) => { + return { ...value, ...config } + }) + return client } else { return axios.create(config) @@ -49,7 +52,7 @@ export class MessagingClient { } private getAxiosConfig({ url }: MessagingOptions): AxiosRequestConfig { - return { baseURL: `${url}/api`, headers: {} } + return { baseURL: `${url}/api` } } }