Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ yarn add @cnamts/vue-cli-plugin-proxy # OR npm install @cnamts/vue-cli-plugin-pr
module.exports = {
pluginOptions: {
proxy: {
enabled: true,
context: '',
options: {
// ...
Expand All @@ -79,7 +80,8 @@ See [http-proxy-middleware](https://www.npmjs.com/package/http-proxy-middleware#
module.exports = {
pluginOptions: {
proxy: {
context: '/api',
enabled: true,
context: '/api',
options: {
target: 'http://www.example.org',
changeOrigin: true
Expand All @@ -96,7 +98,8 @@ module.exports = {
module.exports = {
pluginOptions: {
proxy: {
context: ['/**', '!/dist/**'],
enabled: true,
context: ['/**', '!/dist/**'],
options: {
target: 'http://127.0.0.1:8000',
}
Expand All @@ -107,4 +110,4 @@ module.exports = {

## License

Vue CLI plugin proxy is licensed under a [MIT License](./LICENSE).
Vue CLI plugin proxy is licensed under a [MIT License](./LICENSE).
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var proxy = require('http-proxy-middleware');

module.exports = (api, options) => {
api.configureDevServer((app) => {
app.use(proxy(
options.pluginOptions.proxy.context,
options.pluginOptions.proxy.options
));
});
const opts = options.pluginOptions.proxy
if(opts && (opts.enabled === undefined || opts.enabled)) {
api.configureDevServer((app) => {
app.use(proxy(
opts.context,
opts.options
));
});
}
};