unplugin-https-reverse-proxy 0.0.10 → 0.0.11

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/README.md CHANGED
@@ -17,6 +17,7 @@ UHRP_AUTO_INSTALL_CADDY=true npm i unplugin-https-reverse-proxy --save-dev
17
17
  ```ts
18
18
  interface Options {
19
19
  target: string // <- https target hostname
20
+ showCaddyLog?: boolean // <- default: false
20
21
  }
21
22
  ```
22
23
 
@@ -115,4 +116,10 @@ sudo -E npm run dev # your dev script
115
116
  # windows
116
117
  # use powershell as administrator
117
118
  npm run dev # your dev script
118
- ```
119
+ ```
120
+
121
+ If your broswer shows a not trusted certificate warning, please check the keychain.
122
+
123
+ ![keychain](https://github.com/zcf0508/unplugin-https-reverse-proxy/blob/main/images/Snipaste_2023-11-16_16-59-55.png)
124
+
125
+ More info, you can check [caddy about CA Root](https://caddyserver.com/docs/automatic-https#ca-root).
@@ -275,7 +275,8 @@ var CaddyInstant = class {
275
275
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
276
276
  const {
277
277
  restore = true,
278
- base = "/"
278
+ base = "/",
279
+ showCaddyLog = false
279
280
  } = options || {};
280
281
  if (!this.inited)
281
282
  await this.init();
@@ -291,9 +292,13 @@ var CaddyInstant = class {
291
292
  return reject(err);
292
293
  });
293
294
  child.stderr.on("data", (data) => {
294
- if (data.toString().includes("Error")) {
295
- child.kill();
296
- return reject(data.toString());
295
+ const lines = data.toString().split("\n").map((line) => line.trim());
296
+ for (const line of lines) {
297
+ showCaddyLog && line && console.info(line);
298
+ if (line && JSON.parse(line).level === "error") {
299
+ consola.error(line);
300
+ return reject(line);
301
+ }
297
302
  }
298
303
  });
299
304
  child.stdout.on("data", (_data) => {
@@ -344,7 +349,8 @@ var unpluginFactory = (options) => ({
344
349
  try {
345
350
  const caddy2 = new CaddyInstant();
346
351
  caddy2.run(source, target, {
347
- base
352
+ base,
353
+ showCaddyLog: options.showCaddyLog
348
354
  }).then((stop) => {
349
355
  const colorUrl = (url2) => c.green(url2.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
350
356
  consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -374,7 +380,9 @@ var unpluginFactory = (options) => ({
374
380
  if (caddy)
375
381
  return;
376
382
  caddy = new CaddyInstant();
377
- caddy.run(source, target).then((stop) => {
383
+ caddy.run(source, target, {
384
+ showCaddyLog: options.showCaddyLog
385
+ }).then((stop) => {
378
386
  const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
379
387
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
380
388
  if (stats.hasErrors())
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-5K6D2TTS.js";
4
4
 
5
5
  // src/webpack.ts
6
6
  import { createWebpackPlugin } from "unplugin";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-5K6D2TTS.js";
4
4
 
5
5
  // src/vite.ts
6
6
  import { createVitePlugin } from "unplugin";
package/dist/esbuild.cjs CHANGED
@@ -314,7 +314,8 @@ var CaddyInstant = class {
314
314
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
315
315
  const {
316
316
  restore = true,
317
- base = "/"
317
+ base = "/",
318
+ showCaddyLog = false
318
319
  } = options || {};
319
320
  if (!this.inited)
320
321
  await this.init();
@@ -330,9 +331,13 @@ var CaddyInstant = class {
330
331
  return reject(err);
331
332
  });
332
333
  child.stderr.on("data", (data) => {
333
- if (data.toString().includes("Error")) {
334
- child.kill();
335
- return reject(data.toString());
334
+ const lines = data.toString().split("\n").map((line) => line.trim());
335
+ for (const line of lines) {
336
+ showCaddyLog && line && console.info(line);
337
+ if (line && JSON.parse(line).level === "error") {
338
+ consola.error(line);
339
+ return reject(line);
340
+ }
336
341
  }
337
342
  });
338
343
  child.stdout.on("data", (_data) => {
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
383
388
  try {
384
389
  const caddy2 = new CaddyInstant();
385
390
  caddy2.run(source, target, {
386
- base
391
+ base,
392
+ showCaddyLog: options.showCaddyLog
387
393
  }).then((stop) => {
388
394
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
389
395
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
413
419
  if (caddy)
414
420
  return;
415
421
  caddy = new CaddyInstant();
416
- caddy.run(source, target).then((stop) => {
422
+ caddy.run(source, target, {
423
+ showCaddyLog: options.showCaddyLog
424
+ }).then((stop) => {
417
425
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
418
426
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
419
427
  if (stats.hasErrors())
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-5K6D2TTS.js";
4
4
  import "./chunk-3HKPYCSE.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/index.cjs CHANGED
@@ -313,7 +313,8 @@ var CaddyInstant = class {
313
313
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
314
314
  const {
315
315
  restore = true,
316
- base = "/"
316
+ base = "/",
317
+ showCaddyLog = false
317
318
  } = options || {};
318
319
  if (!this.inited)
319
320
  await this.init();
@@ -329,9 +330,13 @@ var CaddyInstant = class {
329
330
  return reject(err);
330
331
  });
331
332
  child.stderr.on("data", (data) => {
332
- if (data.toString().includes("Error")) {
333
- child.kill();
334
- return reject(data.toString());
333
+ const lines = data.toString().split("\n").map((line) => line.trim());
334
+ for (const line of lines) {
335
+ showCaddyLog && line && console.info(line);
336
+ if (line && JSON.parse(line).level === "error") {
337
+ consola.error(line);
338
+ return reject(line);
339
+ }
335
340
  }
336
341
  });
337
342
  child.stdout.on("data", (_data) => {
@@ -382,7 +387,8 @@ var unpluginFactory = (options) => ({
382
387
  try {
383
388
  const caddy2 = new CaddyInstant();
384
389
  caddy2.run(source, target, {
385
- base
390
+ base,
391
+ showCaddyLog: options.showCaddyLog
386
392
  }).then((stop) => {
387
393
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
388
394
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -412,7 +418,9 @@ var unpluginFactory = (options) => ({
412
418
  if (caddy)
413
419
  return;
414
420
  caddy = new CaddyInstant();
415
- caddy.run(source, target).then((stop) => {
421
+ caddy.run(source, target, {
422
+ showCaddyLog: options.showCaddyLog
423
+ }).then((stop) => {
416
424
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
417
425
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
418
426
  if (stats.hasErrors())
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  src_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-AJ47BPUG.js";
5
+ } from "./chunk-5K6D2TTS.js";
6
6
  import "./chunk-3HKPYCSE.js";
7
7
  export {
8
8
  src_default as default,
package/dist/nuxt.cjs CHANGED
@@ -317,7 +317,8 @@ var CaddyInstant = class {
317
317
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
318
318
  const {
319
319
  restore = true,
320
- base = "/"
320
+ base = "/",
321
+ showCaddyLog = false
321
322
  } = options || {};
322
323
  if (!this.inited)
323
324
  await this.init();
@@ -333,9 +334,13 @@ var CaddyInstant = class {
333
334
  return reject(err);
334
335
  });
335
336
  child.stderr.on("data", (data) => {
336
- if (data.toString().includes("Error")) {
337
- child.kill();
338
- return reject(data.toString());
337
+ const lines = data.toString().split("\n").map((line) => line.trim());
338
+ for (const line of lines) {
339
+ showCaddyLog && line && console.info(line);
340
+ if (line && JSON.parse(line).level === "error") {
341
+ consola.error(line);
342
+ return reject(line);
343
+ }
339
344
  }
340
345
  });
341
346
  child.stdout.on("data", (_data) => {
@@ -386,7 +391,8 @@ var unpluginFactory = (options) => ({
386
391
  try {
387
392
  const caddy2 = new CaddyInstant();
388
393
  caddy2.run(source, target, {
389
- base
394
+ base,
395
+ showCaddyLog: options.showCaddyLog
390
396
  }).then((stop) => {
391
397
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
392
398
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -416,7 +422,9 @@ var unpluginFactory = (options) => ({
416
422
  if (caddy)
417
423
  return;
418
424
  caddy = new CaddyInstant();
419
- caddy.run(source, target).then((stop) => {
425
+ caddy.run(source, target, {
426
+ showCaddyLog: options.showCaddyLog
427
+ }).then((stop) => {
420
428
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
421
429
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
422
430
  if (stats.hasErrors())
package/dist/nuxt.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-FD66DR3R.js";
3
+ } from "./chunk-UGVWTB7L.js";
4
4
  import {
5
5
  webpack_default
6
- } from "./chunk-J2XKEZPC.js";
7
- import "./chunk-AJ47BPUG.js";
6
+ } from "./chunk-BFAT7WWW.js";
7
+ import "./chunk-5K6D2TTS.js";
8
8
  import "./chunk-3HKPYCSE.js";
9
9
 
10
10
  // src/nuxt.ts
package/dist/rollup.cjs CHANGED
@@ -314,7 +314,8 @@ var CaddyInstant = class {
314
314
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
315
315
  const {
316
316
  restore = true,
317
- base = "/"
317
+ base = "/",
318
+ showCaddyLog = false
318
319
  } = options || {};
319
320
  if (!this.inited)
320
321
  await this.init();
@@ -330,9 +331,13 @@ var CaddyInstant = class {
330
331
  return reject(err);
331
332
  });
332
333
  child.stderr.on("data", (data) => {
333
- if (data.toString().includes("Error")) {
334
- child.kill();
335
- return reject(data.toString());
334
+ const lines = data.toString().split("\n").map((line) => line.trim());
335
+ for (const line of lines) {
336
+ showCaddyLog && line && console.info(line);
337
+ if (line && JSON.parse(line).level === "error") {
338
+ consola.error(line);
339
+ return reject(line);
340
+ }
336
341
  }
337
342
  });
338
343
  child.stdout.on("data", (_data) => {
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
383
388
  try {
384
389
  const caddy2 = new CaddyInstant();
385
390
  caddy2.run(source, target, {
386
- base
391
+ base,
392
+ showCaddyLog: options.showCaddyLog
387
393
  }).then((stop) => {
388
394
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
389
395
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
413
419
  if (caddy)
414
420
  return;
415
421
  caddy = new CaddyInstant();
416
- caddy.run(source, target).then((stop) => {
422
+ caddy.run(source, target, {
423
+ showCaddyLog: options.showCaddyLog
424
+ }).then((stop) => {
417
425
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
418
426
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
419
427
  if (stats.hasErrors())
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-5K6D2TTS.js";
4
4
  import "./chunk-3HKPYCSE.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/types.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  interface Options {
2
2
  target: string;
3
+ showCaddyLog?: boolean;
3
4
  }
4
5
 
5
6
  export { Options };
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  interface Options {
2
2
  target: string;
3
+ showCaddyLog?: boolean;
3
4
  }
4
5
 
5
6
  export { Options };
package/dist/vite.cjs CHANGED
@@ -314,7 +314,8 @@ var CaddyInstant = class {
314
314
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
315
315
  const {
316
316
  restore = true,
317
- base = "/"
317
+ base = "/",
318
+ showCaddyLog = false
318
319
  } = options || {};
319
320
  if (!this.inited)
320
321
  await this.init();
@@ -330,9 +331,13 @@ var CaddyInstant = class {
330
331
  return reject(err);
331
332
  });
332
333
  child.stderr.on("data", (data) => {
333
- if (data.toString().includes("Error")) {
334
- child.kill();
335
- return reject(data.toString());
334
+ const lines = data.toString().split("\n").map((line) => line.trim());
335
+ for (const line of lines) {
336
+ showCaddyLog && line && console.info(line);
337
+ if (line && JSON.parse(line).level === "error") {
338
+ consola.error(line);
339
+ return reject(line);
340
+ }
336
341
  }
337
342
  });
338
343
  child.stdout.on("data", (_data) => {
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
383
388
  try {
384
389
  const caddy2 = new CaddyInstant();
385
390
  caddy2.run(source, target, {
386
- base
391
+ base,
392
+ showCaddyLog: options.showCaddyLog
387
393
  }).then((stop) => {
388
394
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
389
395
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
413
419
  if (caddy)
414
420
  return;
415
421
  caddy = new CaddyInstant();
416
- caddy.run(source, target).then((stop) => {
422
+ caddy.run(source, target, {
423
+ showCaddyLog: options.showCaddyLog
424
+ }).then((stop) => {
417
425
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
418
426
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
419
427
  if (stats.hasErrors())
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-FD66DR3R.js";
4
- import "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-UGVWTB7L.js";
4
+ import "./chunk-5K6D2TTS.js";
5
5
  import "./chunk-3HKPYCSE.js";
6
6
  export {
7
7
  vite_default as default
package/dist/webpack.cjs CHANGED
@@ -314,7 +314,8 @@ var CaddyInstant = class {
314
314
  source = source.replace("0.0.0.0", "127.0.0.1").replace("localhost", "127.0.0.1");
315
315
  const {
316
316
  restore = true,
317
- base = "/"
317
+ base = "/",
318
+ showCaddyLog = false
318
319
  } = options || {};
319
320
  if (!this.inited)
320
321
  await this.init();
@@ -330,9 +331,13 @@ var CaddyInstant = class {
330
331
  return reject(err);
331
332
  });
332
333
  child.stderr.on("data", (data) => {
333
- if (data.toString().includes("Error")) {
334
- child.kill();
335
- return reject(data.toString());
334
+ const lines = data.toString().split("\n").map((line) => line.trim());
335
+ for (const line of lines) {
336
+ showCaddyLog && line && console.info(line);
337
+ if (line && JSON.parse(line).level === "error") {
338
+ consola.error(line);
339
+ return reject(line);
340
+ }
336
341
  }
337
342
  });
338
343
  child.stdout.on("data", (_data) => {
@@ -383,7 +388,8 @@ var unpluginFactory = (options) => ({
383
388
  try {
384
389
  const caddy2 = new CaddyInstant();
385
390
  caddy2.run(source, target, {
386
- base
391
+ base,
392
+ showCaddyLog: options.showCaddyLog
387
393
  }).then((stop) => {
388
394
  const colorUrl = (url2) => import_picocolors.default.green(url2.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
389
395
  consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`https://${target}${base}`)}`);
@@ -413,7 +419,9 @@ var unpluginFactory = (options) => ({
413
419
  if (caddy)
414
420
  return;
415
421
  caddy = new CaddyInstant();
416
- caddy.run(source, target).then((stop) => {
422
+ caddy.run(source, target, {
423
+ showCaddyLog: options.showCaddyLog
424
+ }).then((stop) => {
417
425
  const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
418
426
  compiler.hooks.done.tap("unplugin-https-reverse-proxy", (stats) => {
419
427
  if (stats.hasErrors())
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  webpack_default
3
- } from "./chunk-J2XKEZPC.js";
4
- import "./chunk-AJ47BPUG.js";
3
+ } from "./chunk-BFAT7WWW.js";
4
+ import "./chunk-5K6D2TTS.js";
5
5
  import "./chunk-3HKPYCSE.js";
6
6
  export {
7
7
  webpack_default as default
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-https-reverse-proxy",
3
3
  "type": "module",
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "packageManager": "pnpm@8.6.12",
6
6
  "description": "",
7
7
  "license": "MIT",
@@ -81,6 +81,7 @@ function testCaddy() {
81
81
  interface RunOptions {
82
82
  restore: boolean
83
83
  base: string
84
+ showCaddyLog: boolean
84
85
  }
85
86
 
86
87
  export class CaddyInstant {
@@ -161,6 +162,7 @@ export class CaddyInstant {
161
162
  const {
162
163
  restore = true,
163
164
  base = '/',
165
+ showCaddyLog = false,
164
166
  } = options || {}
165
167
 
166
168
  if (!this.inited)
@@ -185,9 +187,16 @@ export class CaddyInstant {
185
187
  })
186
188
 
187
189
  child.stderr.on('data', (data) => {
188
- if ((data.toString() as string).includes('Error')) {
189
- child.kill()
190
- return reject(data.toString())
190
+ const lines = (data.toString() as string).split('\n').map(line => line.trim())
191
+ for (const line of lines) {
192
+ // caddy log
193
+ // eslint-disable-next-line no-console
194
+ showCaddyLog && line && console.info(line)
195
+ if (line && JSON.parse(line).level === 'error') {
196
+ consola.error(line)
197
+ // child.kill()
198
+ return reject(line)
199
+ }
191
200
  }
192
201
  })
193
202
 
package/src/index.ts CHANGED
@@ -40,6 +40,7 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
40
40
  const caddy = new CaddyInstant()
41
41
  caddy.run(source, target, {
42
42
  base,
43
+ showCaddyLog: options.showCaddyLog,
43
44
  }).then((stop) => {
44
45
  const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
45
46
  consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`https://${target}${base}`)}`)
@@ -75,7 +76,9 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
75
76
 
76
77
  caddy = new CaddyInstant()
77
78
 
78
- caddy.run(source, target).then((stop) => {
79
+ caddy.run(source, target, {
80
+ showCaddyLog: options.showCaddyLog,
81
+ }).then((stop) => {
79
82
  const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
80
83
 
81
84
  compiler.hooks.done.tap('unplugin-https-reverse-proxy', (stats) => {
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export interface Options {
2
2
  // define your plugin options here
3
3
  target: string
4
+ showCaddyLog?: boolean
4
5
  }