Skip to content

Commit

Permalink
docs: improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 1, 2021
1 parent f35db51 commit 16c58d3
Showing 1 changed file with 43 additions and 13 deletions.
56 changes: 43 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

✓ ...See [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) docs

⚠ Does not work in generated/static mode!
⚠ Does not work with `nuxt generate` (see [static target](https://nuxtjs.org/docs/2.x/features/deployment-targets#static-hosting)).

## Setup

Expand All @@ -39,22 +39,16 @@ yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
{
modules: [
// Simple usage
'@nuxtjs/proxy',

// With options
['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }]
]
'@nuxtjs/proxy'
],
proxy: {
// see Proxy section
}
}
```

- 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.
Expand Down Expand Up @@ -89,7 +83,10 @@ Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-mat
'/api': 'http://example.com',

// With options
'/api2': { target: 'http://example.com', ws: false },
'/api2': {
target: 'http://example.com',
ws: false
},

// Proxy to backend unix socket
'/api3': {
Expand All @@ -100,6 +97,39 @@ Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-mat
}
```

## Default Options

- `changeOrigin` and `ws` options are enabled by default.

You can provide default options to all proxy targets by passing options to module options:

```js
export default {
modules: [
// Disable ws option to all proxified endpoints
['@nuxtjs/proxy', { ws: false }]
],
proxy: [
'http://example.com/foo',
'http://example.com:8000/api/books/*/**.json',
]
}
```

This will be similar to:

```js
export default {
modules: [
'@nuxtjs/proxy',
],
proxy: [
['http://example.com/foo', { ws: false }],
['http://example.com:8000/api/books/*/**.json', { ws: false }]
]
}
```

## Development

1. Clone this repository
Expand Down

0 comments on commit 16c58d3

Please sign in to comment.