{"id":16612108,"url":"https://github.com/zcf0508/unplugin-https-reverse-proxy","last_synced_at":"2025-12-26T17:32:36.538Z","repository":{"id":207331747,"uuid":"719004303","full_name":"zcf0508/unplugin-https-reverse-proxy","owner":"zcf0508","description":"👻 Add a reverse proxy for your dev service, support `https`.","archived":false,"fork":false,"pushed_at":"2025-05-21T08:38:41.000Z","size":1891,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T16:12:34.905Z","etag":null,"topics":["nuxt","react","rebuild","repack","unplugin","vite","vue","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zcf0508.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["antfu"],"ko_fi":"huali58081","custom":["https://afdian.com/a/huali08"]}},"created_at":"2023-11-15T08:42:48.000Z","updated_at":"2025-05-21T08:38:41.000Z","dependencies_parsed_at":"2024-01-04T12:28:29.429Z","dependency_job_id":"71b59c7c-eb05-4f8d-a769-a6d326fde771","html_url":"https://github.com/zcf0508/unplugin-https-reverse-proxy","commit_stats":{"total_commits":117,"total_committers":2,"mean_commits":58.5,"dds":"0.042735042735042694","last_synced_commit":"0d799acafdf17988c9eeb9d2a7299fa3564a21eb"},"previous_names":["zcf0508/unplugin-https-reverse-proxy"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/zcf0508/unplugin-https-reverse-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcf0508%2Funplugin-https-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcf0508%2Funplugin-https-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcf0508%2Funplugin-https-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcf0508%2Funplugin-https-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zcf0508","download_url":"https://codeload.github.com/zcf0508/unplugin-https-reverse-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcf0508%2Funplugin-https-reverse-proxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260302052,"owners_count":22988741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nuxt","react","rebuild","repack","unplugin","vite","vue","webpack"],"created_at":"2024-10-12T01:40:53.043Z","updated_at":"2025-12-26T17:32:36.510Z","avatar_url":"https://github.com/zcf0508.png","language":"TypeScript","readme":"# unplugin-https-reverse-proxy\n\n[![NPM version](https://img.shields.io/npm/v/unplugin-https-reverse-proxy?color=a1b858\u0026label=)](https://www.npmjs.com/package/unplugin-https-reverse-proxy)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/zcf0508/unplugin-https-reverse-proxy)\n\nA plugin for https reverse proxy, support `vite`、`webpack` and `rspack`.\n\n## Install\n\nSupport set caddy file path by environment variable `UHRP_CADDY_PATH`, default is system cache folder.\n\n```env\n#.env.local\nUHRP_CADDY_PATH=~/tmp/.uhrp\n```\n\n```bash\nnpm i unplugin-https-reverse-proxy --save-dev\n```\n\n```ts\ninterface Options {\n  /** default: true */\n  enable?: boolean\n  /** target hostname */\n  target: string\n  /** default: false */\n  showCaddyLog?: boolean\n  /** default: false */\n  https?: boolean\n}\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport HttpsReverseProxy from 'unplugin-https-reverse-proxy/vite'\n\nexport default defineConfig({\n  plugins: [\n    HttpsReverseProxy({ /* options */ }),\n  ],\n})\n```\n\nExample: [`playground/`](./playground/)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack 5\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// webpack.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  https: false,\n}\n\nmodule.exports = {\n  /* ... */\n  devServer: {\n    client: {\n      // ↓ for HMR\n      webSocketURL: {\n        ...(reverseProxyOptions.enable\n          ? {\n              hostname: reverseProxyOptions.target,\n            }\n          : {}),\n        ...(reverseProxyOptions.enable \u0026\u0026 reverseProxyOptions.https\n          ? {\n              protocol: 'wss',\n              port: 443,\n            }\n          : {})\n      }\n    },\n    setupExitSignals: true,\n    allowedHosts: 'all',\n  },\n  plugins: [\n    require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions)\n  ]\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack 4\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// webpack.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  // https: false, // not support yet\n}\n\nmodule.exports = {\n  /* ... */\n  devServer: {\n    host: '0.0.0.0',\n    disableHostCheck: true,\n  },\n  plugins: [\n    require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions)\n  ]\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRspack\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// rspack.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  https: false,\n}\n\nmodule.exports = {\n  /* ... */\n  devServer: {\n    client: {\n      // ↓ for HMR\n      webSocketURL: {\n        ...(reverseProxyOptions.enable\n          ? {\n              hostname: reverseProxyOptions.target,\n            }\n          : {}),\n        ...(reverseProxyOptions.enable \u0026\u0026 reverseProxyOptions.https\n          ? {\n              protocol: 'wss',\n              port: 443,\n            }\n          : {})\n      }\n    },\n  },\n  plugins: [\n    require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)\n  ]\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRsbuild\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// rsbuild.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  https: false,\n  healthCheck: true,\n}\n\nmodule.exports = {\n  /* ... */\n  dev: {\n    client: {\n      // ↓ for HMR\n      ...(reverseProxyOptions.enable\n        ? {\n            host: reverseProxyOptions.target,\n          }\n        : {}),\n      ...(reverseProxyOptions.enable \u0026\u0026 reverseProxyOptions.https\n        ? {\n            protocol: 'wss',\n            port: '443',\n          }\n        : {})\n    },\n  },\n  tools: {\n    rspack: {\n      plugins: [\n        require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)\n      ]\n    },\n  },\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eNuxt\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// nuxt.config.js\nexport default defineNuxtConfig({\n  modules: [\n    ['unplugin-https-reverse-proxy/nuxt', {\n      /* options */\n      healthCheck: false, // important for nuxt\n    }],\n  ],\n})\n```\n\n**!important:** You need to update the `nuxt dev` script by adding `--fork=false` to enable host restoration.\n\n```json\n// package.json\n\n{\n  \"scripts\": {\n    \"dev\": \"nuxt dev --fork=false\"\n  }\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI 5\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// vue.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  https: false,\n}\n\nmodule.exports = {\n  devServer: {\n    client: {\n      // ↓ for HMR\n      webSocketURL: {\n        ...(reverseProxyOptions.enable\n          ? {\n              hostname: reverseProxyOptions.target,\n            }\n          : {}),\n        ...(reverseProxyOptions.enable \u0026\u0026 reverseProxyOptions.https\n          ? {\n              protocol: 'wss',\n              port: 443,\n            }\n          : {})\n      }\n    },\n    setupExitSignals: true,\n    allowedHosts: 'all',\n  },\n  configureWebpack: {\n    plugins: [\n      require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions),\n    ],\n  },\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI 4\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// vue.config.js\n\n/** @type {Parameters\u003cimport('unplugin-https-reverse-proxy/webpack')['default']\u003e[0]} */\nconst reverseProxyOptions = {\n  enable: false,\n  target: 'xxx',\n  // https: false, // not support yet\n}\n\nmodule.exports = {\n  devServer: {\n    host: '0.0.0.0',\n    disableHostCheck: true,\n  },\n  configureWebpack: {\n    plugins: [\n      require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions),\n    ],\n  },\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## NOTICE!\nYou need delete `caddy` executable file after you updated to `^2.0.0`.\nThe default path is `$TMPDIR/caddy`, and if you set `UHRP_CADDY_PATH`, it will be in the path you set.\n\nPlease check [caddy path](https://github.com/zcf0508/unplugin-https-reverse-proxy/blob/v1.0.0/src/caddy/constants.ts#L17).\n\n## Usage\n\n```bash\n# macOS\nsudo -E npm run dev # your dev script\n#    ^ `-E` is important\n\n# windows\n# use powershell as administrator\nnpm run dev # your dev script\n```\n\nIf your broswer shows a not trusted certificate warning, please check the keychain.\n\n![keychain](https://github.com/zcf0508/unplugin-https-reverse-proxy/blob/main/images/Snipaste_2023-11-16_16-59-55.png)\n\nMore info, you can check [caddy about CA Root](https://caddyserver.com/docs/automatic-https#ca-root).\n","funding_links":["https://github.com/sponsors/antfu","https://ko-fi.com/huali58081","https://afdian.com/a/huali08"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcf0508%2Funplugin-https-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzcf0508%2Funplugin-https-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcf0508%2Funplugin-https-reverse-proxy/lists"}