balm-core 4.27.2 → 4.29.0

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.
@@ -1,34 +1,20 @@
1
1
  import { createProxyMiddleware } from 'http-proxy-middleware';
2
- function handleProxyConfigError() {
3
- const configuration = '{ context: string | array, options: object }';
4
- BalmJS.logger.error('proxy middleware', `Proxy config must be an object (${configuration}) or array ([${configuration}])`);
5
- }
6
2
  function httpProxyMiddleware() {
7
3
  const middleware = [];
8
- const proxyConfig = BalmJS.config.server.proxyConfig;
9
- if (proxyConfig) {
4
+ const proxyOptions = BalmJS.config.server.proxyOptions;
5
+ if (proxyOptions) {
10
6
  try {
11
- if (BalmJS.utils.isObject(proxyConfig)) {
12
- const config = proxyConfig;
13
- if (config.context && config.options) {
14
- middleware.push(createProxyMiddleware(config.context, config.options));
15
- }
16
- else {
17
- handleProxyConfigError();
18
- }
7
+ if (BalmJS.utils.isObject(proxyOptions)) {
8
+ const options = proxyOptions;
9
+ middleware.push(createProxyMiddleware(options));
19
10
  }
20
- else if (BalmJS.utils.isArray(proxyConfig)) {
21
- for (const config of proxyConfig) {
22
- if (config.context && config.options) {
23
- middleware.push(createProxyMiddleware(config.context, config.options));
24
- }
25
- else {
26
- handleProxyConfigError();
27
- }
11
+ else if (BalmJS.utils.isArray(proxyOptions)) {
12
+ for (const options of proxyOptions) {
13
+ middleware.push(createProxyMiddleware(options));
28
14
  }
29
15
  }
30
16
  else {
31
- handleProxyConfigError();
17
+ BalmJS.logger.error('proxy middleware', `Proxy options (https://github.com/chimurai/http-proxy-middleware#options) must be an object or array`);
32
18
  }
33
19
  }
34
20
  catch (error) {