unplugin-https-reverse-proxy 1.0.0-beta.2 → 1.0.0-beta.21
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 +105 -2
- package/dist/chunk-2VGRJ3QS.js +45 -0
- package/dist/chunk-KVE7AVSI.js +700 -0
- package/dist/esbuild.cjs +339 -160
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +339 -160
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -2
- package/dist/nuxt.cjs +275 -234
- package/dist/nuxt.js +24 -22
- package/dist/rollup.cjs +339 -160
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +765 -0
- package/dist/rspack.d.cts +5 -0
- package/dist/rspack.d.ts +5 -0
- package/dist/rspack.js +10 -0
- package/dist/types.cjs +1 -1
- package/dist/utils.cjs +2 -2
- package/dist/utils.js +1 -1
- package/dist/vite.cjs +339 -160
- package/dist/vite.d.cts +1 -2
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +7 -4
- package/dist/webpack.cjs +339 -160
- package/dist/webpack.js +7 -4
- package/package.json +48 -28
- package/scripts/postinstall.cjs +308 -0
- package/src/caddy/constants.ts +14 -1
- package/src/caddy/index.ts +234 -76
- package/src/caddy/utils.ts +18 -0
- package/src/host/index.ts +9 -15
- package/src/index.ts +110 -83
- package/src/nuxt.ts +26 -19
- package/src/rspack.ts +5 -0
- package/dist/chunk-DDD5N75Y.js +0 -11
- package/dist/chunk-N6ZBBGYD.js +0 -516
- package/dist/chunk-RUJE3YFB.js +0 -63
- package/dist/chunk-VGLXVBHU.js +0 -11
- package/scripts/postinstall.ts +0 -19
package/README.md
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/unplugin-https-reverse-proxy)
|
|
4
4
|
|
|
5
|
-
A plugin for https reverse proxy, support `vite` and `
|
|
5
|
+
A plugin for https reverse proxy, support `vite`、`webpack` and `rspack`.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
Support set caddy file path by environment variable `UHRP_CADDY_PATH`, default is system cache folder.
|
|
11
|
+
|
|
12
|
+
```env
|
|
13
|
+
#.env.local
|
|
14
|
+
UHRP_CADDY_PATH=~/tmp/.uhrp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
```bash
|
|
10
19
|
# not auto install caddy when postinstall
|
|
11
20
|
npm i unplugin-https-reverse-proxy --save-dev
|
|
@@ -115,6 +124,90 @@ module.exports = {
|
|
|
115
124
|
|
|
116
125
|
<br></details>
|
|
117
126
|
|
|
127
|
+
<details>
|
|
128
|
+
<summary>Rspack</summary><br>
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// rspack.config.js
|
|
132
|
+
|
|
133
|
+
/** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
|
|
134
|
+
const reverseProxyOptions = {
|
|
135
|
+
enable: false,
|
|
136
|
+
target: 'xxx',
|
|
137
|
+
https: false,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = {
|
|
141
|
+
/* ... */
|
|
142
|
+
devServer: {
|
|
143
|
+
client: {
|
|
144
|
+
// ↓ for HMR
|
|
145
|
+
webSocketURL: {
|
|
146
|
+
...(reverseProxyOptions.enable
|
|
147
|
+
? {
|
|
148
|
+
hostname: reverseProxyOptions.target,
|
|
149
|
+
}
|
|
150
|
+
: {}),
|
|
151
|
+
...(reverseProxyOptions.enable && reverseProxyOptions.https
|
|
152
|
+
? {
|
|
153
|
+
protocol: 'wss',
|
|
154
|
+
port: 443,
|
|
155
|
+
}
|
|
156
|
+
: {})
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
plugins: [
|
|
161
|
+
require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
<br></details>
|
|
167
|
+
|
|
168
|
+
<details>
|
|
169
|
+
<summary>Rsbuild</summary><br>
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
// rsbuild.config.js
|
|
173
|
+
|
|
174
|
+
/** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
|
|
175
|
+
const reverseProxyOptions = {
|
|
176
|
+
enable: false,
|
|
177
|
+
target: 'xxx',
|
|
178
|
+
https: false,
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
module.exports = {
|
|
182
|
+
/* ... */
|
|
183
|
+
dev: {
|
|
184
|
+
client: {
|
|
185
|
+
// ↓ for HMR
|
|
186
|
+
...(reverseProxyOptions.enable
|
|
187
|
+
? {
|
|
188
|
+
host: reverseProxyOptions.target,
|
|
189
|
+
}
|
|
190
|
+
: {}),
|
|
191
|
+
...(reverseProxyOptions.enable && reverseProxyOptions.https
|
|
192
|
+
? {
|
|
193
|
+
protocol: 'wss',
|
|
194
|
+
port: '443',
|
|
195
|
+
}
|
|
196
|
+
: {})
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
tools: {
|
|
200
|
+
rspack: {
|
|
201
|
+
plugins: [
|
|
202
|
+
require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
<br></details>
|
|
210
|
+
|
|
118
211
|
<details>
|
|
119
212
|
<summary>Nuxt</summary><br>
|
|
120
213
|
|
|
@@ -127,7 +220,17 @@ export default defineNuxtConfig({
|
|
|
127
220
|
})
|
|
128
221
|
```
|
|
129
222
|
|
|
130
|
-
|
|
223
|
+
**!important:** You need to update the `nuxt dev` script by adding `--fork=false` to enable host restoration.
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
// package.json
|
|
227
|
+
|
|
228
|
+
{
|
|
229
|
+
"scripts": {
|
|
230
|
+
"dev": "nuxt dev --fork=false"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
131
234
|
|
|
132
235
|
<br></details>
|
|
133
236
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { chmod, readdir, stat } from "node:fs/promises";
|
|
5
|
+
import { execSync } from "node:child_process";
|
|
6
|
+
import { createConsola } from "consola";
|
|
7
|
+
var consola = createConsola({
|
|
8
|
+
level: 3
|
|
9
|
+
}).withTag("reverse-proxy");
|
|
10
|
+
async function chmodRecursive(_path, mode) {
|
|
11
|
+
await chmod(_path, mode);
|
|
12
|
+
if ((await stat(_path)).isDirectory()) {
|
|
13
|
+
const children = await readdir(_path);
|
|
14
|
+
for (const child of children)
|
|
15
|
+
await chmodRecursive(path.join(_path, child), mode);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function once(fn) {
|
|
19
|
+
let called = false;
|
|
20
|
+
return (...args) => {
|
|
21
|
+
if (called)
|
|
22
|
+
return;
|
|
23
|
+
called = true;
|
|
24
|
+
return fn(...args);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function isAdmin() {
|
|
28
|
+
if (process.platform === "win32") {
|
|
29
|
+
try {
|
|
30
|
+
execSync("net session", { stdio: "ignore" });
|
|
31
|
+
return true;
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
return process.getuid && process.getuid() === 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
consola,
|
|
42
|
+
chmodRecursive,
|
|
43
|
+
once,
|
|
44
|
+
isAdmin
|
|
45
|
+
};
|