23
23
24
24
✓ ...See [ http-proxy-middleware] ( https://github.com/chimurai/http-proxy-middleware ) docs
25
25
26
- ⚠ Does not work in generated/ static mode!
26
+ ⚠ Does not work with ` nuxt generate ` (see [ static target ] ( https://nuxtjs.org/docs/2.x/features/deployment-targets#static-hosting ) ).
27
27
28
28
## Setup
29
29
@@ -39,22 +39,16 @@ yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
39
39
{
40
40
modules: [
41
41
// Simple usage
42
- ' @nuxtjs/proxy' ,
43
-
44
- // With options
45
- [ ' @nuxtjs/proxy ' , { pathRewrite : { ' ^/api ' : ' /api/v1 ' } }]
46
- ]
42
+ ' @nuxtjs/proxy'
43
+ ],
44
+ proxy : {
45
+ // see Proxy section
46
+ }
47
47
}
48
48
```
49
49
50
50
- Define as many as proxy middleware you want in ` proxy ` section of ` nuxt.config.js ` (See [ proxy] ( #proxy ) section below)
51
51
52
- ## Options
53
-
54
- - ` changeOrigin ` and ` ws ` options are enabled by default.
55
-
56
- [ optional] You can provide default options to all proxy targets by passing options to module options.
57
-
58
52
## ` proxy `
59
53
60
54
You can provide proxy config using either object or array.
@@ -89,7 +83,10 @@ Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-mat
89
83
' /api' : ' http://example.com' ,
90
84
91
85
// With options
92
- ' /api2' : { target: ' http://example.com' , ws: false },
86
+ ' /api2' : {
87
+ target: ' http://example.com' ,
88
+ ws: false
89
+ },
93
90
94
91
// Proxy to backend unix socket
95
92
' /api3' : {
@@ -100,6 +97,39 @@ Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-mat
100
97
}
101
98
```
102
99
100
+ ## Default Options
101
+
102
+ - ` changeOrigin ` and ` ws ` options are enabled by default.
103
+
104
+ You can provide default options to all proxy targets by passing options to module options:
105
+
106
+ ``` js
107
+ export default {
108
+ modules: [
109
+ // Disable ws option to all proxified endpoints
110
+ [' @nuxtjs/proxy' , { ws: false }]
111
+ ],
112
+ proxy: [
113
+ ' http://example.com/foo' ,
114
+ ' http://example.com:8000/api/books/*/**.json' ,
115
+ ]
116
+ }
117
+ ```
118
+
119
+ This will be similar to:
120
+
121
+ ``` js
122
+ export default {
123
+ modules: [
124
+ ' @nuxtjs/proxy' ,
125
+ ],
126
+ proxy: [
127
+ [' http://example.com/foo' , { ws: false }],
128
+ [' http://example.com:8000/api/books/*/**.json' , { ws: false }]
129
+ ]
130
+ }
131
+ ```
132
+
103
133
## Development
104
134
105
135
1 . Clone this repository
0 commit comments