Skip to content

Commit 792c6de

Browse files
authored
Merge pull request #1 from clemyan/master
Add option for disabling the proxy
2 parents 8e692ff + fdad3e2 commit 792c6de

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ yarn add @cnamts/vue-cli-plugin-proxy # OR npm install @cnamts/vue-cli-plugin-pr
5757
module.exports = {
5858
pluginOptions: {
5959
proxy: {
60+
enabled: true,
6061
context: '',
6162
options: {
6263
// ...
@@ -79,7 +80,8 @@ See [http-proxy-middleware](https://www.npmjs.com/package/http-proxy-middleware#
7980
module.exports = {
8081
pluginOptions: {
8182
proxy: {
82-
context: '/api',
83+
enabled: true,
84+
context: '/api',
8385
options: {
8486
target: 'http://www.example.org',
8587
changeOrigin: true
@@ -96,7 +98,8 @@ module.exports = {
9698
module.exports = {
9799
pluginOptions: {
98100
proxy: {
99-
context: ['/**', '!/dist/**'],
101+
enabled: true,
102+
context: ['/**', '!/dist/**'],
100103
options: {
101104
target: 'http://127.0.0.1:8000',
102105
}
@@ -107,4 +110,4 @@ module.exports = {
107110

108111
## License
109112

110-
Vue CLI plugin proxy is licensed under a [MIT License](./LICENSE).
113+
Vue CLI plugin proxy is licensed under a [MIT License](./LICENSE).

index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
var proxy = require('http-proxy-middleware');
22

33
module.exports = (api, options) => {
4-
api.configureDevServer((app) => {
5-
app.use(proxy(
6-
options.pluginOptions.proxy.context,
7-
options.pluginOptions.proxy.options
8-
));
9-
});
4+
const opts = options.pluginOptions.proxy
5+
if(opts && (opts.enabled === undefined || opts.enabled)) {
6+
api.configureDevServer((app) => {
7+
app.use(proxy(
8+
opts.context,
9+
opts.options
10+
));
11+
});
12+
}
1013
};

0 commit comments

Comments
 (0)