Created
September 25, 2020 10:57
-
-
Save eyecatchup/b179cd83922ee346ccca95f6d7de0976 to your computer and use it in GitHub Desktop.
(Vue.js) Webpack dev server config to use a (corporate) proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HttpsProxyAgent = require('https-proxy-agent') | |
const proxy = new HttpsProxyAgent('http://1.2.3.4:3128') | |
module.exports = { | |
// ... | |
configureWebpack: { | |
devServer: { | |
// ... | |
proxy: { | |
'/api/*': { | |
target: 'https://your-remote-backend.com', | |
ws: true, | |
changeOrigin: true, | |
agent: proxy | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HttpsProxyAgent = require('https-proxy-agent') | |
const proxy = new HttpsProxyAgent('http://1.2.3.4:3128') | |
module.exports = (env) => ({ | |
// ... | |
devServer: { | |
// ... | |
proxy: { | |
'/api/*': { | |
target: 'https://your-remote-backend.com', | |
ws: true, | |
changeOrigin: true, | |
agent: proxy | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment