This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+136
View File
@@ -0,0 +1,136 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.0.0](https://github.com/nuxt-community/proxy-module/compare/v1.3.3...v2.0.0) (2020-06-03)
### ⚠ BREAKING CHANGES
* Bumping major version as http-proxy-middleware may introduce some usage regressions
### Features
* bump to 2.x ([57eb492](https://github.com/nuxt-community/proxy-module/commit/57eb492c42cea6b6e90e4348065da308274fbc8a))
* upgrade to `http-proxy-middleware` 1.0.1 ([0277f6d](https://github.com/nuxt-community/proxy-module/commit/0277f6d0c753a73b2b4ab15223c1a5f9da0085ca))
### Bug Fixes
* **module:** use logger ([#40](https://github.com/nuxt-community/proxy-module/issues/40)) ([6bfbcad](https://github.com/nuxt-community/proxy-module/commit/6bfbcade52c364647c26084eb66a16ff6a7c7e11))
## [1.3.3](https://github.com/nuxt-community/proxy-module/compare/v1.3.2...v1.3.3) (2019-03-02)
### Bug Fixes
* **module:** generate warn if not SPA and increase coverage ([#31](https://github.com/nuxt-community/proxy-module/issues/31)) ([8baafc9](https://github.com/nuxt-community/proxy-module/commit/8baafc9))
## [1.3.2](https://github.com/nuxt-community/proxy-module/compare/v1.3.1...v1.3.2) (2019-02-18)
### Bug Fixes
* skip generate warn for now because of SPA ([7b23097](https://github.com/nuxt-community/proxy-module/commit/7b23097))
<a name="1.3.1"></a>
## [1.3.1](https://github.com/nuxt-community/proxy-module/compare/v1.3.0...v1.3.1) (2018-10-30)
### Bug Fixes
* add hint for "universal" mode only ([#10](https://github.com/nuxt-community/proxy-module/issues/10)) ([c78b122](https://github.com/nuxt-community/proxy-module/commit/c78b122))
<a name="1.3.0"></a>
# [1.3.0](https://github.com/nuxt-community/proxy-module/compare/v1.2.4...v1.3.0) (2018-10-29)
### Features
* upgrade dependencies ([331fa23](https://github.com/nuxt-community/proxy-module/commit/331fa23))
<a name="1.2.4"></a>
## [1.2.4](https://github.com/nuxt-community/proxy-module/compare/v1.2.3...v1.2.4) (2018-03-31)
<a name="1.2.3"></a>
## [1.2.3](https://github.com/nuxt-community/proxy-module/compare/v1.2.2...v1.2.3) (2018-03-31)
### Bug Fixes
* hide debug logs ([66c1905](https://github.com/nuxt-community/proxy-module/commit/66c1905))
<a name="1.2.2"></a>
## [1.2.2](https://github.com/nuxt-community/proxy-module/compare/v1.2.1...v1.2.2) (2018-03-31)
<a name="1.2.1"></a>
## [1.2.1](https://github.com/nuxt-community/proxy-module/compare/v1.2.0...v1.2.1) (2018-03-31)
<a name="1.2.0"></a>
# [1.2.0](https://github.com/nuxt-community/proxy-module/compare/v1.1.4...v1.2.0) (2018-03-31)
<a name="1.1.4"></a>
## 1.1.4 (2018-01-28)
<a name="1.1.3"></a>
## [1.1.3](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.2...@nuxtjs/proxy@1.1.3) (2017-11-20)
**Note:** Version bump only for package @nuxtjs/proxy
<a name="1.1.2"></a>
## [1.1.2](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.1...@nuxtjs/proxy@1.1.2) (2017-09-05)
### Bug Fixes
* **proxy:** disable prefix ([3e2e70f](https://github.com/nuxt/modules/commit/3e2e70f))
<a name="1.1.1"></a>
## [1.1.1](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.0...@nuxtjs/proxy@1.1.1) (2017-06-09)
### Bug Fixes
* **plugin:** normalize array alternative form path ([811b5a9](https://github.com/nuxt/modules/commit/811b5a9))
<a name="1.1.0"></a>
# 1.1.0 (2017-06-07)
### Bug Fixes
* **proxy:** normalize target in object mode ([e9d4026](https://github.com/nuxt/modules/commit/e9d4026))
### Features
* proxy module ([6dfca4d](https://github.com/nuxt/modules/commit/6dfca4d))
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Nuxt Community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated Vendored Executable
+132
View File
@@ -0,0 +1,132 @@
# @nuxtjs/proxy
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Circle CI][circle-ci-src]][circle-ci-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
> The one-liner node.js http-proxy middleware solution for Nuxt.js using [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
[📖 **Release Notes**](./CHANGELOG.md)
✨ Do you know that [Axios Module](https://github.com/nuxt-community/axios-module) has built in support for Proxy Module?
## Features
✓ Path rewrites
✓ Host based router (useful for staging/test)
✓ Logs / Proxy Events
✓ WebSockets
✓ Auth / Cookie
✓ ...and more! (see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) docs)
⚠ Does not work in generated/static mode!
## Setup
1. Add `@nuxtjs/proxy` dependency to your project
```bash
yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
```
2. Add `@nuxtjs/proxy` to the `modules` section of `nuxt.config.js`
```js
{
modules: [
// Simple usage
'@nuxtjs/proxy',
// With options
['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }]
]
}
```
- Define as many as proxy middleware you want in `proxy` section of `nuxt.config.js` (See [proxy](#proxy) section below)
## Options
- `changeOrigin` and `ws` options are enabled by default.
[optional] You can provide default options to all proxy targets by passing options to module options.
## `proxy`
You can provide proxy config using either object or array.
### Array mode
You can use magic [shorthands](https://github.com/chimurai/http-proxy-middleware#shorthand)
```js
{
proxy: [
// Proxies /foo to http://example.com/foo
'http://example.com/foo',
// Proxies /api/books/*/**.json to http://example.com:8000
'http://example.com:8000/api/books/*/**.json',
// You can also pass more options
[ 'http://example.com/foo', { ws: false } ]
]
}
```
### Object mode
Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-matching)
```js
{
proxy: {
// Simple proxy
'/api': 'http://example.com',
// With options
'/api2': { target: 'http://example.com', ws: false },
// Proxy to backend unix socket
'/api3': {
changeOrigin: false,
target: { socketPath: '/var/run/http-sockets/backend.sock' }
}
}
}
```
## Development
1. Clone this repository
2. Install dependencies using `yarn install` or `npm install`
3. Start development server using `npm run dev`
## License
[MIT License](./LICENSE)
Copyright (c) Nuxt Community
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/proxy/latest.svg?style=flat-square
[npm-version-href]: https://npmjs.com/package/@nuxtjs/proxy
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/proxy.svg?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/proxy
[circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/proxy-module.svg?style=flat-square
[circle-ci-href]: https://circleci.com/gh/nuxt-community/proxy-module
[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/proxy-module.svg?style=flat-square
[codecov-href]: https://codecov.io/gh/nuxt-community/proxy-module
[license-src]: https://img.shields.io/npm/l/@nuxtjs/proxy.svg?style=flat-square
[license-href]: https://npmjs.com/package/@nuxtjs/proxy
+3
View File
@@ -0,0 +1,3 @@
const consola = require('consola')
module.exports = consola.withScope('nuxt:proxy')
+70
View File
@@ -0,0 +1,70 @@
const { createProxyMiddleware } = require('http-proxy-middleware')
const logger = require('./logger')
// Redirect info ~> debug
logger.info = logger.debug
function proxyModule (options) {
if (!this.options.proxy) {
// No proxy defined
logger.warn('No proxy defined on top level.')
return
}
if (this.options.mode !== 'spa') {
this.nuxt.hook('generate:before', () => {
logger.warn('The module `@nuxtjs/proxy` does not work in generated mode.')
})
}
// Defaults
const defaults = Object.assign(
{
// Required for virtual hosted sites
changeOrigin: true,
// Proxy webSockets
ws: true,
// Use consola as default logger
logProvider: () => logger
},
options
)
delete defaults.src
// Normalize options.proxy to middleware arguments
const applyDefaults = o => Object.assign({}, defaults, o)
const normalizeTarget = o => (typeof o === 'object' ? o : { target: o })
const proxy = []
if (Array.isArray(this.options.proxy)) {
// Array mode
this.options.proxy.forEach((p) => {
if (Array.isArray(p)) {
proxy.push([p[0], applyDefaults(normalizeTarget(p[1]))])
} else {
proxy.push([p, applyDefaults()])
}
})
} else {
// Object mode
Object.keys(this.options.proxy).forEach((context) => {
proxy.push([
context,
applyDefaults(normalizeTarget(this.options.proxy[context]))
])
})
}
// Register middleware
proxy.forEach((args) => {
// https://github.com/chimurai/http-proxy-middleware
this.addServerMiddleware({
prefix: false, // http-proxy-middleware uses req.originalUrl
handler: createProxyMiddleware(...args)
})
})
}
module.exports = proxyModule
module.exports.meta = require('../package.json')
+79
View File
@@ -0,0 +1,79 @@
{
"_args": [
[
"@nuxtjs/proxy@2.0.0",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
]
],
"_from": "@nuxtjs/proxy@2.0.0",
"_id": "@nuxtjs/proxy@2.0.0",
"_inBundle": false,
"_integrity": "sha512-ewiOLAhfQlE/QWiQkHH0MQBYrtTRRSuz5SqDly1Zy/M3cN9bxqWd9d5Ty/GnU3nLtwsfW64TrRKuTw8/gT1nFQ==",
"_location": "/@nuxtjs/proxy",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/proxy@2.0.0",
"name": "@nuxtjs/proxy",
"escapedName": "@nuxtjs%2fproxy",
"scope": "@nuxtjs",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"/@nuxtjs/axios"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/proxy/-/proxy-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"bugs": {
"url": "https://github.com/nuxt-community/proxy-module/issues"
},
"contributors": [
{
"name": "Pooya Parsa",
"email": "pooya@pi0.ir"
}
],
"dependencies": {
"consola": "^2.11.3",
"http-proxy-middleware": "^1.0.4"
},
"description": "The one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware",
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"codecov": "latest",
"eslint": "latest",
"husky": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"request": "latest",
"request-promise-native": "latest",
"standard-version": "latest"
},
"files": [
"lib"
],
"homepage": "https://github.com/nuxt-community/proxy-module#readme",
"license": "MIT",
"main": "lib/module.js",
"name": "@nuxtjs/proxy",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-community/proxy-module.git"
},
"scripts": {
"dev": "nuxt test/fixture",
"lint": "eslint --ext .js,.vue lib test",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"version": "2.0.0"
}