unplugin-https-reverse-proxy 2.0.3-beta.1 → 3.0.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.
package/dist/rollup.cjs CHANGED
@@ -13437,10 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
- base: "string"
13443
+ base: "string",
13444
+ healthCheck: "boolean"
13444
13445
  });
13445
13446
  var CaddyContext = type({
13446
13447
  caddy_root: "string",
@@ -13476,9 +13477,9 @@ var caddyTemplate = `{
13476
13477
  }
13477
13478
 
13478
13479
  {% for p in proxies %}
13479
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13480
13481
  {{ p.tls }}
13481
- reverse_proxy http://{{ p.source }} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13482
13483
  health_uri {{ p.base }}
13483
13484
  health_interval 2s
13484
13485
  health_timeout 5s
@@ -13486,11 +13487,6 @@ var caddyTemplate = `{
13486
13487
  unhealthy_status 502 503 504 404
13487
13488
  lb_try_duration 3s
13488
13489
  lb_try_interval 300ms
13489
- health_headers {
13490
- Accept text/html
13491
- Accept-Encoding gzip, deflate, br
13492
- User-Agent Caddy-Health-Check
13493
- }
13494
13490
 
13495
13491
  @error status 502 503 504 404
13496
13492
  handle_response @error {
@@ -13500,6 +13496,7 @@ var caddyTemplate = `{
13500
13496
  }
13501
13497
  }
13502
13498
  }
13499
+ {% endif %}
13503
13500
  }
13504
13501
  {% endfor %}
13505
13502
  `;
@@ -13644,7 +13641,7 @@ var supportList = [
13644
13641
  // src/caddy/config.ts
13645
13642
  function useCaddyConfig() {
13646
13643
  const configContentRef = signal("{}");
13647
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13648
13645
  try {
13649
13646
  return JSON.parse(configContentRef());
13650
13647
  } catch {
@@ -13667,26 +13664,26 @@ function useCaddyConfig() {
13667
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13668
13665
  setConfigContent();
13669
13666
  });
13670
- function writeCaddyConfig2(_proxies) {
13671
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13672
13669
  _proxies.forEach((p) => {
13673
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13674
13671
  proxies[index] = p;
13675
13672
  });
13676
13673
  const content = JSON.stringify(proxies, null, 2);
13677
13674
  configContentRef(content);
13678
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13679
13676
  }
13680
- async function cleanUp2() {
13677
+ async function cleanUp() {
13681
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13682
13679
  });
13683
13680
  configContentRef("{}");
13684
13681
  watchCaddyConfig.close();
13685
13682
  }
13686
13683
  return {
13687
- configJsonRef: configJsonRef2,
13688
- writeCaddyConfig: writeCaddyConfig2,
13689
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13690
13687
  };
13691
13688
  }
13692
13689
 
@@ -13820,7 +13817,13 @@ function testCaddy() {
13820
13817
  });
13821
13818
  });
13822
13819
  }
13823
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13824
13827
  var CaddyInstant = class {
13825
13828
  constructor() {
13826
13829
  this.inited = false;
@@ -13872,7 +13875,8 @@ var CaddyInstant = class {
13872
13875
  restore = true,
13873
13876
  base = "/",
13874
13877
  showCaddyLog = false,
13875
- https = false
13878
+ https = false,
13879
+ healthCheck = true
13876
13880
  } = options || {};
13877
13881
  this._source = source;
13878
13882
  this._target = target;
@@ -13885,15 +13889,18 @@ var CaddyInstant = class {
13885
13889
  const proxies = [
13886
13890
  {
13887
13891
  target: targetHost,
13888
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13889
13893
  tls: https ? "tls internal" : "",
13890
13894
  source,
13891
- base
13895
+ base,
13896
+ healthCheck
13892
13897
  }
13893
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13894
13900
  writeCaddyConfig(proxies);
13895
13901
  this._stopEffects.push(
13896
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13897
13904
  const proxies2 = Object.values(configJsonRef() || {});
13898
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13899
13906
  const ctx = validateTemplateContext({
@@ -14028,7 +14035,9 @@ ${line}
14028
14035
  });
14029
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14030
14037
  });
14031
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14032
14041
  } catch (e) {
14033
14042
  consola.error(e);
14034
14043
  }
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-6ESO3Y2K.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/rspack.cjs CHANGED
@@ -13436,10 +13436,11 @@ var Liquid = class _Liquid {
13436
13436
  // src/caddy/caddyfile.ts
13437
13437
  var ProxyType = type({
13438
13438
  target: "string",
13439
- port_suffix: "string",
13439
+ portSuffix: "string",
13440
13440
  tls: "string",
13441
13441
  source: "string",
13442
- base: "string"
13442
+ base: "string",
13443
+ healthCheck: "boolean"
13443
13444
  });
13444
13445
  var CaddyContext = type({
13445
13446
  caddy_root: "string",
@@ -13475,9 +13476,9 @@ var caddyTemplate = `{
13475
13476
  }
13476
13477
 
13477
13478
  {% for p in proxies %}
13478
- {{ p.target }}{{ p.port_suffix }} {
13479
+ {{ p.target }}{{ p.portSuffix }} {
13479
13480
  {{ p.tls }}
13480
- reverse_proxy http://{{ p.source }} {
13481
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13481
13482
  health_uri {{ p.base }}
13482
13483
  health_interval 2s
13483
13484
  health_timeout 5s
@@ -13485,11 +13486,6 @@ var caddyTemplate = `{
13485
13486
  unhealthy_status 502 503 504 404
13486
13487
  lb_try_duration 3s
13487
13488
  lb_try_interval 300ms
13488
- health_headers {
13489
- Accept text/html
13490
- Accept-Encoding gzip, deflate, br
13491
- User-Agent Caddy-Health-Check
13492
- }
13493
13489
 
13494
13490
  @error status 502 503 504 404
13495
13491
  handle_response @error {
@@ -13499,6 +13495,7 @@ var caddyTemplate = `{
13499
13495
  }
13500
13496
  }
13501
13497
  }
13498
+ {% endif %}
13502
13499
  }
13503
13500
  {% endfor %}
13504
13501
  `;
@@ -13643,7 +13640,7 @@ var supportList = [
13643
13640
  // src/caddy/config.ts
13644
13641
  function useCaddyConfig() {
13645
13642
  const configContentRef = signal("{}");
13646
- const configJsonRef2 = computed(() => {
13643
+ const configJsonRef = computed(() => {
13647
13644
  try {
13648
13645
  return JSON.parse(configContentRef());
13649
13646
  } catch {
@@ -13666,26 +13663,26 @@ function useCaddyConfig() {
13666
13663
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13667
13664
  setConfigContent();
13668
13665
  });
13669
- function writeCaddyConfig2(_proxies) {
13670
- const proxies = configJsonRef2() || {};
13666
+ function writeCaddyConfig(_proxies) {
13667
+ const proxies = configJsonRef() || {};
13671
13668
  _proxies.forEach((p) => {
13672
- const index = `${p.target}${p.port_suffix}`;
13669
+ const index = `${p.target}${p.portSuffix}`;
13673
13670
  proxies[index] = p;
13674
13671
  });
13675
13672
  const content = JSON.stringify(proxies, null, 2);
13676
13673
  configContentRef(content);
13677
13674
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13678
13675
  }
13679
- async function cleanUp2() {
13676
+ async function cleanUp() {
13680
13677
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13681
13678
  });
13682
13679
  configContentRef("{}");
13683
13680
  watchCaddyConfig.close();
13684
13681
  }
13685
13682
  return {
13686
- configJsonRef: configJsonRef2,
13687
- writeCaddyConfig: writeCaddyConfig2,
13688
- cleanUp: cleanUp2
13683
+ configJsonRef,
13684
+ writeCaddyConfig,
13685
+ cleanUp
13689
13686
  };
13690
13687
  }
13691
13688
 
@@ -13819,7 +13816,13 @@ function testCaddy() {
13819
13816
  });
13820
13817
  });
13821
13818
  }
13822
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13819
+ var caddyConfig;
13820
+ function getCaddyConfig() {
13821
+ if (!caddyConfig) {
13822
+ caddyConfig = useCaddyConfig();
13823
+ }
13824
+ return caddyConfig;
13825
+ }
13823
13826
  var CaddyInstant = class {
13824
13827
  constructor() {
13825
13828
  this.inited = false;
@@ -13871,7 +13874,8 @@ var CaddyInstant = class {
13871
13874
  restore = true,
13872
13875
  base = "/",
13873
13876
  showCaddyLog = false,
13874
- https = false
13877
+ https = false,
13878
+ healthCheck = true
13875
13879
  } = options || {};
13876
13880
  this._source = source;
13877
13881
  this._target = target;
@@ -13884,15 +13888,18 @@ var CaddyInstant = class {
13884
13888
  const proxies = [
13885
13889
  {
13886
13890
  target: targetHost,
13887
- port_suffix: https ? "" : ":80",
13891
+ portSuffix: https ? "" : ":80",
13888
13892
  tls: https ? "tls internal" : "",
13889
13893
  source,
13890
- base
13894
+ base,
13895
+ healthCheck
13891
13896
  }
13892
13897
  ];
13898
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13899
  writeCaddyConfig(proxies);
13894
13900
  this._stopEffects.push(
13895
13901
  effect(async () => {
13902
+ const { configJsonRef } = getCaddyConfig();
13896
13903
  const proxies2 = Object.values(configJsonRef() || {});
13897
13904
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13905
  const ctx = validateTemplateContext({
@@ -14027,7 +14034,9 @@ ${line}
14027
14034
  });
14028
14035
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14036
  });
14030
- await cleanUp();
14037
+ if (caddyConfig) {
14038
+ await caddyConfig.cleanUp();
14039
+ }
14031
14040
  } catch (e) {
14032
14041
  consola.error(e);
14033
14042
  }
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-6ESO3Y2K.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/types.d.cts CHANGED
@@ -4,6 +4,7 @@ interface Options {
4
4
  showCaddyLog?: boolean;
5
5
  /** default `false` */
6
6
  https?: boolean;
7
+ healthCheck?: boolean;
7
8
  }
8
9
 
9
10
  export type { Options };
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ interface Options {
4
4
  showCaddyLog?: boolean;
5
5
  /** default `false` */
6
6
  https?: boolean;
7
+ healthCheck?: boolean;
7
8
  }
8
9
 
9
10
  export type { Options };
package/dist/vite.cjs CHANGED
@@ -13437,10 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
- base: "string"
13443
+ base: "string",
13444
+ healthCheck: "boolean"
13444
13445
  });
13445
13446
  var CaddyContext = type({
13446
13447
  caddy_root: "string",
@@ -13476,9 +13477,9 @@ var caddyTemplate = `{
13476
13477
  }
13477
13478
 
13478
13479
  {% for p in proxies %}
13479
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13480
13481
  {{ p.tls }}
13481
- reverse_proxy http://{{ p.source }} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13482
13483
  health_uri {{ p.base }}
13483
13484
  health_interval 2s
13484
13485
  health_timeout 5s
@@ -13486,11 +13487,6 @@ var caddyTemplate = `{
13486
13487
  unhealthy_status 502 503 504 404
13487
13488
  lb_try_duration 3s
13488
13489
  lb_try_interval 300ms
13489
- health_headers {
13490
- Accept text/html
13491
- Accept-Encoding gzip, deflate, br
13492
- User-Agent Caddy-Health-Check
13493
- }
13494
13490
 
13495
13491
  @error status 502 503 504 404
13496
13492
  handle_response @error {
@@ -13500,6 +13496,7 @@ var caddyTemplate = `{
13500
13496
  }
13501
13497
  }
13502
13498
  }
13499
+ {% endif %}
13503
13500
  }
13504
13501
  {% endfor %}
13505
13502
  `;
@@ -13644,7 +13641,7 @@ var supportList = [
13644
13641
  // src/caddy/config.ts
13645
13642
  function useCaddyConfig() {
13646
13643
  const configContentRef = signal("{}");
13647
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13648
13645
  try {
13649
13646
  return JSON.parse(configContentRef());
13650
13647
  } catch {
@@ -13667,26 +13664,26 @@ function useCaddyConfig() {
13667
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13668
13665
  setConfigContent();
13669
13666
  });
13670
- function writeCaddyConfig2(_proxies) {
13671
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13672
13669
  _proxies.forEach((p) => {
13673
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13674
13671
  proxies[index] = p;
13675
13672
  });
13676
13673
  const content = JSON.stringify(proxies, null, 2);
13677
13674
  configContentRef(content);
13678
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13679
13676
  }
13680
- async function cleanUp2() {
13677
+ async function cleanUp() {
13681
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13682
13679
  });
13683
13680
  configContentRef("{}");
13684
13681
  watchCaddyConfig.close();
13685
13682
  }
13686
13683
  return {
13687
- configJsonRef: configJsonRef2,
13688
- writeCaddyConfig: writeCaddyConfig2,
13689
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13690
13687
  };
13691
13688
  }
13692
13689
 
@@ -13820,7 +13817,13 @@ function testCaddy() {
13820
13817
  });
13821
13818
  });
13822
13819
  }
13823
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13824
13827
  var CaddyInstant = class {
13825
13828
  constructor() {
13826
13829
  this.inited = false;
@@ -13872,7 +13875,8 @@ var CaddyInstant = class {
13872
13875
  restore = true,
13873
13876
  base = "/",
13874
13877
  showCaddyLog = false,
13875
- https = false
13878
+ https = false,
13879
+ healthCheck = true
13876
13880
  } = options || {};
13877
13881
  this._source = source;
13878
13882
  this._target = target;
@@ -13885,15 +13889,18 @@ var CaddyInstant = class {
13885
13889
  const proxies = [
13886
13890
  {
13887
13891
  target: targetHost,
13888
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13889
13893
  tls: https ? "tls internal" : "",
13890
13894
  source,
13891
- base
13895
+ base,
13896
+ healthCheck
13892
13897
  }
13893
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13894
13900
  writeCaddyConfig(proxies);
13895
13901
  this._stopEffects.push(
13896
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13897
13904
  const proxies2 = Object.values(configJsonRef() || {});
13898
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13899
13906
  const ctx = validateTemplateContext({
@@ -14028,7 +14035,9 @@ ${line}
14028
14035
  });
14029
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14030
14037
  });
14031
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14032
14041
  } catch (e) {
14033
14042
  consola.error(e);
14034
14043
  }
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-6ESO3Y2K.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -13437,10 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
- base: "string"
13443
+ base: "string",
13444
+ healthCheck: "boolean"
13444
13445
  });
13445
13446
  var CaddyContext = type({
13446
13447
  caddy_root: "string",
@@ -13476,9 +13477,9 @@ var caddyTemplate = `{
13476
13477
  }
13477
13478
 
13478
13479
  {% for p in proxies %}
13479
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13480
13481
  {{ p.tls }}
13481
- reverse_proxy http://{{ p.source }} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13482
13483
  health_uri {{ p.base }}
13483
13484
  health_interval 2s
13484
13485
  health_timeout 5s
@@ -13486,11 +13487,6 @@ var caddyTemplate = `{
13486
13487
  unhealthy_status 502 503 504 404
13487
13488
  lb_try_duration 3s
13488
13489
  lb_try_interval 300ms
13489
- health_headers {
13490
- Accept text/html
13491
- Accept-Encoding gzip, deflate, br
13492
- User-Agent Caddy-Health-Check
13493
- }
13494
13490
 
13495
13491
  @error status 502 503 504 404
13496
13492
  handle_response @error {
@@ -13500,6 +13496,7 @@ var caddyTemplate = `{
13500
13496
  }
13501
13497
  }
13502
13498
  }
13499
+ {% endif %}
13503
13500
  }
13504
13501
  {% endfor %}
13505
13502
  `;
@@ -13644,7 +13641,7 @@ var supportList = [
13644
13641
  // src/caddy/config.ts
13645
13642
  function useCaddyConfig() {
13646
13643
  const configContentRef = signal("{}");
13647
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13648
13645
  try {
13649
13646
  return JSON.parse(configContentRef());
13650
13647
  } catch {
@@ -13667,26 +13664,26 @@ function useCaddyConfig() {
13667
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13668
13665
  setConfigContent();
13669
13666
  });
13670
- function writeCaddyConfig2(_proxies) {
13671
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13672
13669
  _proxies.forEach((p) => {
13673
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13674
13671
  proxies[index] = p;
13675
13672
  });
13676
13673
  const content = JSON.stringify(proxies, null, 2);
13677
13674
  configContentRef(content);
13678
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13679
13676
  }
13680
- async function cleanUp2() {
13677
+ async function cleanUp() {
13681
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13682
13679
  });
13683
13680
  configContentRef("{}");
13684
13681
  watchCaddyConfig.close();
13685
13682
  }
13686
13683
  return {
13687
- configJsonRef: configJsonRef2,
13688
- writeCaddyConfig: writeCaddyConfig2,
13689
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13690
13687
  };
13691
13688
  }
13692
13689
 
@@ -13820,7 +13817,13 @@ function testCaddy() {
13820
13817
  });
13821
13818
  });
13822
13819
  }
13823
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13824
13827
  var CaddyInstant = class {
13825
13828
  constructor() {
13826
13829
  this.inited = false;
@@ -13872,7 +13875,8 @@ var CaddyInstant = class {
13872
13875
  restore = true,
13873
13876
  base = "/",
13874
13877
  showCaddyLog = false,
13875
- https = false
13878
+ https = false,
13879
+ healthCheck = true
13876
13880
  } = options || {};
13877
13881
  this._source = source;
13878
13882
  this._target = target;
@@ -13885,15 +13889,18 @@ var CaddyInstant = class {
13885
13889
  const proxies = [
13886
13890
  {
13887
13891
  target: targetHost,
13888
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13889
13893
  tls: https ? "tls internal" : "",
13890
13894
  source,
13891
- base
13895
+ base,
13896
+ healthCheck
13892
13897
  }
13893
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13894
13900
  writeCaddyConfig(proxies);
13895
13901
  this._stopEffects.push(
13896
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13897
13904
  const proxies2 = Object.values(configJsonRef() || {});
13898
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13899
13906
  const ctx = validateTemplateContext({
@@ -14028,7 +14035,9 @@ ${line}
14028
14035
  });
14029
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14030
14037
  });
14031
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14032
14041
  } catch (e) {
14033
14042
  consola.error(e);
14034
14043
  }
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-6ESO3Y2K.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/webpack.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-https-reverse-proxy",
3
3
  "type": "module",
4
- "version": "2.0.3-beta.1",
4
+ "version": "3.0.0",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
@@ -163,6 +163,7 @@
163
163
  "dev": "tsup --watch src",
164
164
  "build:fix": "tsx scripts/postbuild.ts",
165
165
  "lint": "eslint .",
166
+ "typecheck": "tsc --noEmit",
166
167
  "play": "npm -C examples/vite run dev",
167
168
  "play:rsbuild": "npm -C examples/rsbuild run dev",
168
169
  "play:nuxt": "npm -C examples/nuxt run dev",
@@ -3,10 +3,11 @@ import { Liquid } from 'liquidjs'
3
3
 
4
4
  export const ProxyType = type({
5
5
  target: 'string',
6
- port_suffix: 'string',
6
+ portSuffix: 'string',
7
7
  tls: 'string',
8
8
  source: 'string',
9
9
  base: 'string',
10
+ healthCheck: 'boolean',
10
11
  })
11
12
 
12
13
  const CaddyContext = type({
@@ -46,9 +47,9 @@ export const caddyTemplate = `{
46
47
  }
47
48
 
48
49
  {% for p in proxies %}
49
- {{ p.target }}{{ p.port_suffix }} {
50
+ {{ p.target }}{{ p.portSuffix }} {
50
51
  {{ p.tls }}
51
- reverse_proxy http://{{ p.source }} {
52
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
52
53
  health_uri {{ p.base }}
53
54
  health_interval 2s
54
55
  health_timeout 5s
@@ -56,11 +57,6 @@ export const caddyTemplate = `{
56
57
  unhealthy_status 502 503 504 404
57
58
  lb_try_duration 3s
58
59
  lb_try_interval 300ms
59
- health_headers {
60
- Accept text/html
61
- Accept-Encoding gzip, deflate, br
62
- User-Agent Caddy-Health-Check
63
- }
64
60
 
65
61
  @error status 502 503 504 404
66
62
  handle_response @error {
@@ -70,6 +66,7 @@ export const caddyTemplate = `{
70
66
  }
71
67
  }
72
68
  }
69
+ {% endif %}
73
70
  }
74
71
  {% endfor %}
75
72
  `