unplugin-https-reverse-proxy 1.0.0-beta.18 → 1.0.0-beta.20

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.
@@ -391,7 +391,23 @@ var CaddyInstant = class {
391
391
  this.caddyfile = `${this.caddyfile}
392
392
  ${target.split(":")[0]}${https ? "" : ":80"} {
393
393
  ${https ? "tls internal" : ""}
394
- reverse_proxy http://${source}
394
+ reverse_proxy http://${source} {
395
+ health_uri /
396
+ health_interval 2s
397
+ health_timeout 5s
398
+ fail_duration 2s
399
+ unhealthy_status 502 503 504 404
400
+ lb_try_duration 3s
401
+ lb_try_interval 300ms
402
+
403
+ @error status 502 503 504 404
404
+ handle_response @error {
405
+ respond * 503 {
406
+ body "Service Unavailable"
407
+ close
408
+ }
409
+ }
410
+ }
395
411
  }
396
412
 
397
413
  `;
@@ -458,14 +474,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
458
474
  this._caddyChild.on("error", (err) => {
459
475
  return reject(err);
460
476
  });
461
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
477
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
462
478
  const lines = data.toString().split("\n").map((line) => line.trim());
463
479
  for (const line of lines) {
464
480
  showCaddyLog && line && console.info(line);
465
481
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
466
- consola.error(`${line}
482
+ if (line.includes("parsing caddyfile tokens")) {
483
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
484
+
485
+ ${line}
486
+ `);
487
+ await this.baseCleanup();
488
+ process3.exit();
489
+ } else {
490
+ consola.error(`${line}
467
491
  `);
468
- return reject(line);
492
+ return reject(line);
493
+ }
469
494
  }
470
495
  if (line.includes("config file changed"))
471
496
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/esbuild.cjs CHANGED
@@ -460,7 +460,23 @@ var CaddyInstant = class {
460
460
  this.caddyfile = `${this.caddyfile}
461
461
  ${target.split(":")[0]}${https ? "" : ":80"} {
462
462
  ${https ? "tls internal" : ""}
463
- reverse_proxy http://${source}
463
+ reverse_proxy http://${source} {
464
+ health_uri /
465
+ health_interval 2s
466
+ health_timeout 5s
467
+ fail_duration 2s
468
+ unhealthy_status 502 503 504 404
469
+ lb_try_duration 3s
470
+ lb_try_interval 300ms
471
+
472
+ @error status 502 503 504 404
473
+ handle_response @error {
474
+ respond * 503 {
475
+ body "Service Unavailable"
476
+ close
477
+ }
478
+ }
479
+ }
464
480
  }
465
481
 
466
482
  `;
@@ -527,14 +543,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
527
543
  this._caddyChild.on("error", (err) => {
528
544
  return reject(err);
529
545
  });
530
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
546
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
531
547
  const lines = data.toString().split("\n").map((line) => line.trim());
532
548
  for (const line of lines) {
533
549
  showCaddyLog && line && console.info(line);
534
550
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
535
- consola.error(`${line}
551
+ if (line.includes("parsing caddyfile tokens")) {
552
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
553
+
554
+ ${line}
555
+ `);
556
+ await this.baseCleanup();
557
+ import_node_process4.default.exit();
558
+ } else {
559
+ consola.error(`${line}
536
560
  `);
537
- return reject(line);
561
+ return reject(line);
562
+ }
538
563
  }
539
564
  if (line.includes("config file changed"))
540
565
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import "./chunk-2VGRJ3QS.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/index.cjs CHANGED
@@ -460,7 +460,23 @@ var CaddyInstant = class {
460
460
  this.caddyfile = `${this.caddyfile}
461
461
  ${target.split(":")[0]}${https ? "" : ":80"} {
462
462
  ${https ? "tls internal" : ""}
463
- reverse_proxy http://${source}
463
+ reverse_proxy http://${source} {
464
+ health_uri /
465
+ health_interval 2s
466
+ health_timeout 5s
467
+ fail_duration 2s
468
+ unhealthy_status 502 503 504 404
469
+ lb_try_duration 3s
470
+ lb_try_interval 300ms
471
+
472
+ @error status 502 503 504 404
473
+ handle_response @error {
474
+ respond * 503 {
475
+ body "Service Unavailable"
476
+ close
477
+ }
478
+ }
479
+ }
464
480
  }
465
481
 
466
482
  `;
@@ -527,14 +543,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
527
543
  this._caddyChild.on("error", (err) => {
528
544
  return reject(err);
529
545
  });
530
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
546
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
531
547
  const lines = data.toString().split("\n").map((line) => line.trim());
532
548
  for (const line of lines) {
533
549
  showCaddyLog && line && console.info(line);
534
550
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
535
- consola.error(`${line}
551
+ if (line.includes("parsing caddyfile tokens")) {
552
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
553
+
554
+ ${line}
555
+ `);
556
+ await this.baseCleanup();
557
+ import_node_process4.default.exit();
558
+ } else {
559
+ consola.error(`${line}
536
560
  `);
537
- return reject(line);
561
+ return reject(line);
562
+ }
538
563
  }
539
564
  if (line.includes("config file changed"))
540
565
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  unplugin,
4
4
  unpluginFactory,
5
5
  vitePrintUrls
6
- } from "./chunk-ZDL3GBDQ.js";
6
+ } from "./chunk-I6DP2OII.js";
7
7
  import "./chunk-2VGRJ3QS.js";
8
8
  export {
9
9
  src_default as default,
package/dist/nuxt.cjs CHANGED
@@ -462,7 +462,23 @@ var CaddyInstant = class {
462
462
  this.caddyfile = `${this.caddyfile}
463
463
  ${target.split(":")[0]}${https ? "" : ":80"} {
464
464
  ${https ? "tls internal" : ""}
465
- reverse_proxy http://${source}
465
+ reverse_proxy http://${source} {
466
+ health_uri /
467
+ health_interval 2s
468
+ health_timeout 5s
469
+ fail_duration 2s
470
+ unhealthy_status 502 503 504 404
471
+ lb_try_duration 3s
472
+ lb_try_interval 300ms
473
+
474
+ @error status 502 503 504 404
475
+ handle_response @error {
476
+ respond * 503 {
477
+ body "Service Unavailable"
478
+ close
479
+ }
480
+ }
481
+ }
466
482
  }
467
483
 
468
484
  `;
@@ -529,14 +545,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
529
545
  this._caddyChild.on("error", (err) => {
530
546
  return reject(err);
531
547
  });
532
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
548
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
533
549
  const lines = data.toString().split("\n").map((line) => line.trim());
534
550
  for (const line of lines) {
535
551
  showCaddyLog && line && console.info(line);
536
552
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
537
- consola.error(`${line}
553
+ if (line.includes("parsing caddyfile tokens")) {
554
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
555
+
556
+ ${line}
557
+ `);
558
+ await this.baseCleanup();
559
+ import_node_process4.default.exit();
560
+ } else {
561
+ consola.error(`${line}
538
562
  `);
539
- return reject(line);
563
+ return reject(line);
564
+ }
540
565
  }
541
566
  if (line.includes("config file changed"))
542
567
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/nuxt.d.cts CHANGED
@@ -3,6 +3,6 @@ import { Options } from './types.cjs';
3
3
 
4
4
  interface ModuleOptions extends Options {
5
5
  }
6
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
7
7
 
8
8
  export { type ModuleOptions, _default as default };
package/dist/nuxt.d.ts CHANGED
@@ -3,6 +3,6 @@ import { Options } from './types.js';
3
3
 
4
4
  interface ModuleOptions extends Options {
5
5
  }
6
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
7
7
 
8
8
  export { type ModuleOptions, _default as default };
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  vitePrintUrls
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import {
5
5
  consola,
6
6
  isAdmin
package/dist/rollup.cjs CHANGED
@@ -460,7 +460,23 @@ var CaddyInstant = class {
460
460
  this.caddyfile = `${this.caddyfile}
461
461
  ${target.split(":")[0]}${https ? "" : ":80"} {
462
462
  ${https ? "tls internal" : ""}
463
- reverse_proxy http://${source}
463
+ reverse_proxy http://${source} {
464
+ health_uri /
465
+ health_interval 2s
466
+ health_timeout 5s
467
+ fail_duration 2s
468
+ unhealthy_status 502 503 504 404
469
+ lb_try_duration 3s
470
+ lb_try_interval 300ms
471
+
472
+ @error status 502 503 504 404
473
+ handle_response @error {
474
+ respond * 503 {
475
+ body "Service Unavailable"
476
+ close
477
+ }
478
+ }
479
+ }
464
480
  }
465
481
 
466
482
  `;
@@ -527,14 +543,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
527
543
  this._caddyChild.on("error", (err) => {
528
544
  return reject(err);
529
545
  });
530
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
546
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
531
547
  const lines = data.toString().split("\n").map((line) => line.trim());
532
548
  for (const line of lines) {
533
549
  showCaddyLog && line && console.info(line);
534
550
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
535
- consola.error(`${line}
551
+ if (line.includes("parsing caddyfile tokens")) {
552
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
553
+
554
+ ${line}
555
+ `);
556
+ await this.baseCleanup();
557
+ import_node_process4.default.exit();
558
+ } else {
559
+ consola.error(`${line}
536
560
  `);
537
- return reject(line);
561
+ return reject(line);
562
+ }
538
563
  }
539
564
  if (line.includes("config file changed"))
540
565
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import "./chunk-2VGRJ3QS.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/rspack.cjs CHANGED
@@ -459,7 +459,23 @@ var CaddyInstant = class {
459
459
  this.caddyfile = `${this.caddyfile}
460
460
  ${target.split(":")[0]}${https ? "" : ":80"} {
461
461
  ${https ? "tls internal" : ""}
462
- reverse_proxy http://${source}
462
+ reverse_proxy http://${source} {
463
+ health_uri /
464
+ health_interval 2s
465
+ health_timeout 5s
466
+ fail_duration 2s
467
+ unhealthy_status 502 503 504 404
468
+ lb_try_duration 3s
469
+ lb_try_interval 300ms
470
+
471
+ @error status 502 503 504 404
472
+ handle_response @error {
473
+ respond * 503 {
474
+ body "Service Unavailable"
475
+ close
476
+ }
477
+ }
478
+ }
463
479
  }
464
480
 
465
481
  `;
@@ -526,14 +542,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
526
542
  this._caddyChild.on("error", (err) => {
527
543
  return reject(err);
528
544
  });
529
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
545
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
530
546
  const lines = data.toString().split("\n").map((line) => line.trim());
531
547
  for (const line of lines) {
532
548
  showCaddyLog && line && console.info(line);
533
549
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
534
- consola.error(`${line}
550
+ if (line.includes("parsing caddyfile tokens")) {
551
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
552
+
553
+ ${line}
554
+ `);
555
+ await this.baseCleanup();
556
+ import_node_process4.default.exit();
557
+ } else {
558
+ consola.error(`${line}
535
559
  `);
536
- return reject(line);
560
+ return reject(line);
561
+ }
537
562
  }
538
563
  if (line.includes("config file changed"))
539
564
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import "./chunk-2VGRJ3QS.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import * as _consola from 'consola';
1
+ import * as consola_dist_core from 'consola/dist/core';
2
2
 
3
- declare const consola: _consola.ConsolaInstance;
3
+ declare const consola: consola_dist_core.ConsolaInstance;
4
4
  declare function chmodRecursive(_path: string, mode: number): Promise<void>;
5
5
  declare function once<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
6
6
  declare function isAdmin(): boolean | undefined;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import * as _consola from 'consola';
1
+ import * as consola_dist_core from 'consola/dist/core';
2
2
 
3
- declare const consola: _consola.ConsolaInstance;
3
+ declare const consola: consola_dist_core.ConsolaInstance;
4
4
  declare function chmodRecursive(_path: string, mode: number): Promise<void>;
5
5
  declare function once<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
6
6
  declare function isAdmin(): boolean | undefined;
package/dist/vite.cjs CHANGED
@@ -460,7 +460,23 @@ var CaddyInstant = class {
460
460
  this.caddyfile = `${this.caddyfile}
461
461
  ${target.split(":")[0]}${https ? "" : ":80"} {
462
462
  ${https ? "tls internal" : ""}
463
- reverse_proxy http://${source}
463
+ reverse_proxy http://${source} {
464
+ health_uri /
465
+ health_interval 2s
466
+ health_timeout 5s
467
+ fail_duration 2s
468
+ unhealthy_status 502 503 504 404
469
+ lb_try_duration 3s
470
+ lb_try_interval 300ms
471
+
472
+ @error status 502 503 504 404
473
+ handle_response @error {
474
+ respond * 503 {
475
+ body "Service Unavailable"
476
+ close
477
+ }
478
+ }
479
+ }
464
480
  }
465
481
 
466
482
  `;
@@ -527,14 +543,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
527
543
  this._caddyChild.on("error", (err) => {
528
544
  return reject(err);
529
545
  });
530
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
546
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
531
547
  const lines = data.toString().split("\n").map((line) => line.trim());
532
548
  for (const line of lines) {
533
549
  showCaddyLog && line && console.info(line);
534
550
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
535
- consola.error(`${line}
551
+ if (line.includes("parsing caddyfile tokens")) {
552
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
553
+
554
+ ${line}
555
+ `);
556
+ await this.baseCleanup();
557
+ import_node_process4.default.exit();
558
+ } else {
559
+ consola.error(`${line}
536
560
  `);
537
- return reject(line);
561
+ return reject(line);
562
+ }
538
563
  }
539
564
  if (line.includes("config file changed"))
540
565
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import "./chunk-2VGRJ3QS.js";
5
5
 
6
6
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -460,7 +460,23 @@ var CaddyInstant = class {
460
460
  this.caddyfile = `${this.caddyfile}
461
461
  ${target.split(":")[0]}${https ? "" : ":80"} {
462
462
  ${https ? "tls internal" : ""}
463
- reverse_proxy http://${source}
463
+ reverse_proxy http://${source} {
464
+ health_uri /
465
+ health_interval 2s
466
+ health_timeout 5s
467
+ fail_duration 2s
468
+ unhealthy_status 502 503 504 404
469
+ lb_try_duration 3s
470
+ lb_try_interval 300ms
471
+
472
+ @error status 502 503 504 404
473
+ handle_response @error {
474
+ respond * 503 {
475
+ body "Service Unavailable"
476
+ close
477
+ }
478
+ }
479
+ }
464
480
  }
465
481
 
466
482
  `;
@@ -527,14 +543,23 @@ ${target.split(":")[0]}${https ? "" : ":80"} {
527
543
  this._caddyChild.on("error", (err) => {
528
544
  return reject(err);
529
545
  });
530
- (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", (data) => {
546
+ (_a = this._caddyChild.stderr) == null ? void 0 : _a.on("data", async (data) => {
531
547
  const lines = data.toString().split("\n").map((line) => line.trim());
532
548
  for (const line of lines) {
533
549
  showCaddyLog && line && console.info(line);
534
550
  if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
535
- consola.error(`${line}
551
+ if (line.includes("parsing caddyfile tokens")) {
552
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
553
+
554
+ ${line}
555
+ `);
556
+ await this.baseCleanup();
557
+ import_node_process4.default.exit();
558
+ } else {
559
+ consola.error(`${line}
536
560
  `);
537
- return reject(line);
561
+ return reject(line);
562
+ }
538
563
  }
539
564
  if (line.includes("config file changed"))
540
565
  consola.success("Detect added a new reverse proxy config, restarted.\n");
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-ZDL3GBDQ.js";
3
+ } from "./chunk-I6DP2OII.js";
4
4
  import "./chunk-2VGRJ3QS.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": "1.0.0-beta.18",
4
+ "version": "1.0.0-beta.20",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
@@ -192,7 +192,23 @@ export class CaddyInstant {
192
192
  this.caddyfile = `${this.caddyfile}
193
193
  ${target.split(':')[0]}${https ? '' : ':80'} {
194
194
  ${https ? 'tls internal' : ''}
195
- reverse_proxy http://${source}
195
+ reverse_proxy http://${source} {
196
+ health_uri /
197
+ health_interval 2s
198
+ health_timeout 5s
199
+ fail_duration 2s
200
+ unhealthy_status 502 503 504 404
201
+ lb_try_duration 3s
202
+ lb_try_interval 300ms
203
+
204
+ @error status 502 503 504 404
205
+ handle_response @error {
206
+ respond * 503 {
207
+ body "Service Unavailable"
208
+ close
209
+ }
210
+ }
211
+ }
196
212
  }
197
213
 
198
214
  `
@@ -277,16 +293,23 @@ ${target.split(':')[0]}${https ? '' : ':80'} {
277
293
  return reject(err)
278
294
  })
279
295
 
280
- this._caddyChild!.stderr?.on('data', (data) => {
296
+ this._caddyChild!.stderr?.on('data', async (data) => {
281
297
  const lines = (data.toString() as string).split('\n').map(line => line.trim())
282
298
  for (const line of lines) {
283
299
  // caddy log
284
300
  // eslint-disable-next-line no-console
285
301
  showCaddyLog && line && console.info(line)
286
302
  if (line.includes('Error:') || (line && JSON.parse(line).level === 'error')) {
287
- consola.error(`${line}\n`)
288
- // child.kill()
289
- return reject(line)
303
+ if (line.includes('parsing caddyfile tokens')) {
304
+ consola.error('Caddyfile syntax error, please contact the author:\n', `${this.caddyfile}\n\n${line}\n`)
305
+ await this.baseCleanup()
306
+ process.exit()
307
+ }
308
+ else {
309
+ consola.error(`${line}\n`)
310
+ // child.kill()
311
+ return reject(line)
312
+ }
290
313
  }
291
314
  if (line.includes('config file changed'))
292
315
  consola.success('Detect added a new reverse proxy config, restarted.\n')