unplugin-https-reverse-proxy 1.0.0-beta.2 → 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.
package/dist/nuxt.js CHANGED
@@ -1,19 +1,14 @@
1
- import {
2
- vite_default
3
- } from "./chunk-DDD5N75Y.js";
4
- import {
5
- webpack_default
6
- } from "./chunk-VGLXVBHU.js";
7
1
  import {
8
2
  vitePrintUrls
9
- } from "./chunk-N6ZBBGYD.js";
3
+ } from "./chunk-I6DP2OII.js";
10
4
  import {
11
5
  consola,
12
- once
13
- } from "./chunk-RUJE3YFB.js";
6
+ isAdmin
7
+ } from "./chunk-2VGRJ3QS.js";
14
8
 
15
9
  // src/nuxt.ts
16
- import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
10
+ import process from "node:process";
11
+ import { defineNuxtModule } from "@nuxt/kit";
17
12
  import "@nuxt/schema";
18
13
  var nuxt_default = defineNuxtModule({
19
14
  meta: {
@@ -21,21 +16,28 @@ var nuxt_default = defineNuxtModule({
21
16
  configKey: "unpluginHttpsReverseProxy"
22
17
  },
23
18
  setup(options, _nuxt) {
24
- addVitePlugin(() => vite_default(options));
25
- addWebpackPlugin(() => webpack_default(options));
26
- let url = "";
19
+ if (process.env.NODE_ENV !== "development")
20
+ return;
21
+ const {
22
+ enable = true,
23
+ target = ""
24
+ } = options;
25
+ if (!enable)
26
+ return;
27
+ if (!isAdmin()) {
28
+ consola.warn("please run as administrator");
29
+ return;
30
+ }
31
+ if (!target) {
32
+ consola.fail("please provide target");
33
+ return;
34
+ }
27
35
  _nuxt.hook("listen", (_, listener) => {
28
- url = listener.url;
29
- });
30
- _nuxt.hook("vite:serverCreated", once((server) => {
36
+ const url = listener.url;
31
37
  const source = new URL(url).host;
32
- if (!options.target) {
33
- consola.fail("please provide target");
34
- return;
35
- }
36
38
  const base = _nuxt.options.app.baseURL || "/";
37
- vitePrintUrls(server, options, source, options.target, base);
38
- }));
39
+ vitePrintUrls(options, source, options.target, base);
40
+ });
39
41
  }
40
42
  });
41
43
  export {