Created
August 24, 2018 20:00
-
-
Save atomize/7262f5b65d5449fa53dd75d5f4144866 to your computer and use it in GitHub Desktop.
Advanced proxy setup for webpack development server
This file contains hidden or 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
// https://raw.githubusercontent.com/webpack/webpack-dev-server/master/examples/general/proxy-advanced/webpack.config.js | |
'use strict'; | |
// our setup function adds behind-the-scenes bits to the config that all of our | |
// examples need | |
const { setup } = require('../../util'); | |
module.exports = setup({ | |
context: __dirname, | |
entry: './app.js', | |
devServer: { | |
proxy: { | |
'/api': { | |
target: 'http://jsonplaceholder.typicode.com/', | |
changeOrigin: true, | |
pathRewrite: { | |
'^/api': '' | |
}, | |
bypass(req) { | |
if (req.url === '/api/nope') { | |
return '/bypass.html'; | |
} | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment