unplugin-https-reverse-proxy 1.0.0-beta.9 → 2.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/README.md +17 -3
- package/dist/chunk-2P7SUCQ3.js +63 -0
- package/dist/{chunk-ZSHTX2B6.js → chunk-SO2FMQ2Q.js} +324 -135
- package/dist/esbuild.cjs +352 -160
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +352 -160
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +325 -142
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +7 -7
- package/dist/rollup.cjs +352 -160
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +352 -160
- package/dist/rspack.js +2 -2
- package/dist/types.cjs +1 -1
- package/dist/utils.cjs +26 -6
- package/dist/utils.d.cts +6 -4
- package/dist/utils.d.ts +6 -4
- package/dist/utils.js +5 -1
- package/dist/vite.cjs +352 -160
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +352 -160
- package/dist/webpack.js +2 -2
- package/package.json +38 -32
- package/scripts/postinstall.cjs +314 -0
- package/src/caddy/constants.ts +3 -2
- package/src/caddy/index.ts +254 -102
- package/src/caddy/utils.ts +24 -6
- package/src/host/index.ts +18 -23
- package/src/index.ts +68 -25
- package/src/nuxt.ts +10 -8
- package/src/utils.ts +33 -6
- package/dist/chunk-RUJE3YFB.js +0 -63
- package/scripts/postinstall.ts +0 -19
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@ A plugin for https reverse proxy, support `vite`、`webpack` and `rspack`.
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
Support set caddy file path by environment variable `UHRP_CADDY_PATH`, default is system cache folder.
|
|
11
10
|
|
|
12
11
|
```env
|
|
@@ -14,7 +13,6 @@ Support set caddy file path by environment variable `UHRP_CADDY_PATH`, default i
|
|
|
14
13
|
UHRP_CADDY_PATH=~/tmp/.uhrp
|
|
15
14
|
```
|
|
16
15
|
|
|
17
|
-
|
|
18
16
|
```bash
|
|
19
17
|
# not auto install caddy when postinstall
|
|
20
18
|
npm i unplugin-https-reverse-proxy --save-dev
|
|
@@ -220,7 +218,17 @@ export default defineNuxtConfig({
|
|
|
220
218
|
})
|
|
221
219
|
```
|
|
222
220
|
|
|
223
|
-
|
|
221
|
+
**!important:** You need to update the `nuxt dev` script by adding `--fork=false` to enable host restoration.
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
// package.json
|
|
225
|
+
|
|
226
|
+
{
|
|
227
|
+
"scripts": {
|
|
228
|
+
"dev": "nuxt dev --fork=false"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
224
232
|
|
|
225
233
|
<br></details>
|
|
226
234
|
|
|
@@ -296,6 +304,12 @@ module.exports = {
|
|
|
296
304
|
|
|
297
305
|
<br></details>
|
|
298
306
|
|
|
307
|
+
## NOTICE!
|
|
308
|
+
You need delete `caddy` executable file after you updated to `^2.0.0`.
|
|
309
|
+
The default path is `$TMPDIR/caddy`, and if you set `UHRP_CADDY_PATH`, it will be in the path you set.
|
|
310
|
+
|
|
311
|
+
Please check [caddy path](https://github.com/zcf0508/unplugin-https-reverse-proxy/blob/v1.0.0/src/caddy/constants.ts#L17).
|
|
312
|
+
|
|
299
313
|
## Usage
|
|
300
314
|
|
|
301
315
|
```bash
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import { chmod, readdir, stat } from "node:fs/promises";
|
|
4
|
+
import { networkInterfaces } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { createConsola } from "consola";
|
|
8
|
+
import c from "picocolors";
|
|
9
|
+
import qrcode from "qrcode-terminal";
|
|
10
|
+
var consola = createConsola({
|
|
11
|
+
level: 3
|
|
12
|
+
}).withTag("reverse-proxy");
|
|
13
|
+
async function chmodRecursive(_path, mode) {
|
|
14
|
+
await chmod(_path, mode);
|
|
15
|
+
if ((await stat(_path)).isDirectory()) {
|
|
16
|
+
const children = await readdir(_path);
|
|
17
|
+
for (const child of children)
|
|
18
|
+
await chmodRecursive(path.join(_path, child), mode);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function once(fn) {
|
|
22
|
+
let called = false;
|
|
23
|
+
return (...args) => {
|
|
24
|
+
if (called)
|
|
25
|
+
return;
|
|
26
|
+
called = true;
|
|
27
|
+
return fn(...args);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function isAdmin() {
|
|
31
|
+
if (process.platform === "win32") {
|
|
32
|
+
try {
|
|
33
|
+
execSync("net session", { stdio: "ignore" });
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
return !!(process.getuid && process.getuid() === 0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getIpv4List() {
|
|
43
|
+
const interfaces = networkInterfaces();
|
|
44
|
+
return Object.values(interfaces).flatMap((nInterface) => nInterface ?? []).filter(
|
|
45
|
+
(detail) => detail.address && (detail.family === "IPv4" || detail.family === 4)
|
|
46
|
+
).filter((detail) => detail.family === "IPv4" && !detail.internal).map((detail) => detail.address);
|
|
47
|
+
}
|
|
48
|
+
async function generateQrcode(input) {
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
qrcode.generate(input, { small: true }, (code) => {
|
|
51
|
+
resolve(code.split("\n").map((line) => c.bgBlack(c.white(line))).join("\n"));
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
consola,
|
|
58
|
+
chmodRecursive,
|
|
59
|
+
once,
|
|
60
|
+
isAdmin,
|
|
61
|
+
getIpv4List,
|
|
62
|
+
generateQrcode
|
|
63
|
+
};
|