@nuxtjs/proxy
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -6,2 +6,13 @@ # Change Log | ||
<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> | ||
@@ -8,0 +19,0 @@ ## [1.1.1](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.0...@nuxtjs/proxy@1.1.1) (2017-06-09) |
@@ -44,3 +44,5 @@ const Proxy = require('http-proxy-middleware') | ||
proxy.forEach(args => { | ||
this.options.serverMiddleware.push(Proxy.apply(undefined, args)) | ||
const middleware = Proxy.apply(undefined, args) | ||
middleware.prefix = false // Don't add router base | ||
this.options.serverMiddleware.push(middleware) | ||
}) | ||
@@ -47,0 +49,0 @@ } |
{ | ||
"name": "@nuxtjs/proxy", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Proxy | ||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/proxy.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/proxy) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/proxy/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/proxy) | ||
> The one-liner node.js http-proxy middleware solution for Nuxt.js using | ||
@@ -18,50 +21,55 @@ [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) | ||
- Add `@nuxtjs/proxy` dependency using yarn or npm to your project | ||
- Add `@nuxtjs/proxy` module to `nuxt.config.js`: | ||
- Add `@nuxtjs/proxy` to `modules` section of `nuxt.config.js` | ||
```js | ||
modules: [ | ||
'@nuxtjs/proxy' | ||
] | ||
{ | ||
modules: [ | ||
// Simple usage | ||
'@nuxtjs/proxy', | ||
// With options | ||
['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }], | ||
] | ||
} | ||
```` | ||
- [optional] You can also provide default options to all proxy targets: | ||
- By default `changeOrigin` and `ws` options are already enabled. | ||
- See [http-proxy-options](https://github.com/chimurai/http-proxy-middleware#http-proxy-options) | ||
for available options. | ||
```js | ||
modules: [ | ||
{ | ||
src: '@nuxtjs/proxy', | ||
pathRewrite: { | ||
'^/api' : '/api/v1' // Rewrite path | ||
} | ||
} | ||
] | ||
```` | ||
- Define as many as proxy middleware you want in `proxy` section of `nuxt.config.js`: (see section below) | ||
- Define as many as proxy middleware you want in `proxy` section of `nuxt.config.js` (See [proxy](#proxy) section below) | ||
## Proxy Options | ||
You can provide options using either object or array form. | ||
## Options | ||
- `changeOrigin` and `ws` options are enabled by default. | ||
Array mode (You can use magic [shorthands](https://github.com/chimurai/http-proxy-middleware#shorthand)) | ||
[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)) | ||
### 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 } | ||
// Simple proxy | ||
'/api': 'http://example.com', | ||
// With options | ||
'/api2': { target: 'http://example.com', ws: false } | ||
} | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4805
42
75