Created
February 11, 2019 21:21
-
-
Save samuelstevens9/5872e72ac915dfc1a8ae2fdcef323899 to your computer and use it in GitHub Desktop.
Simple setupProxy.js for CRA
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
// src/setupProxy.js | |
const proxy = require('http-proxy-middleware') | |
const pkg = require('../package.json') | |
const target = process.env.PROXY || pkg.proxy | |
// tslint:disable-next-line:no-console | |
console.log("setupProxy",target); | |
module.exports = function(app) { | |
// app.use(proxy({ target })); | |
app.use(proxy('/api', { | |
// pathRewrite: { '^/api': '' }, | |
secure: false, | |
target, | |
})); | |
}; | |
// module.exports = app => { | |
// if(target){ | |
// app.use((req, res, next) =>{ | |
// // tslint:disable-next-line:no-console | |
// console.log("setupProxy",target); | |
// req.accepts('text/html') ? next() : proxy({ target })(req, res, next) | |
// } | |
// } | |
// } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment