Skip to content

Commit c1ffc2c

Browse files
Configure Webpack to proxy /api (#52)
* Configured webpack to proxy /api * code review'd * Update webpack.config.js --------- Co-authored-by: Gabe <[email protected]>
1 parent 60f1ad6 commit c1ffc2c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

webpack.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const path = require('path');
22
const BundleAnalyzerPlugin =
33
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
44

5+
// change this to your local instance of the CSSS API
6+
// source: https://github.com/csss/csss-site-backend
7+
// (if changed, don't commit your change please!)
8+
const API_INSTANCE = 'http://localhost:3049';
9+
510
module.exports = {
611
entry: {
712
react: ['react', 'react-dom'],
@@ -34,7 +39,14 @@ module.exports = {
3439
directory: path.join(__dirname, 'public')
3540
},
3641
compress: true,
37-
port: 8080
42+
port: 8080,
43+
proxy: [
44+
{
45+
context: ['/api'],
46+
target: API_INSTANCE,
47+
pathRewrite: { '^/api': '' }
48+
}
49+
]
3850
},
3951
plugins: [
4052
new BundleAnalyzerPlugin({

0 commit comments

Comments
 (0)