Basic proxy setup for create-react-app to work with remote backend
let proxy = require('http-proxy-middleware'); | |
module.exports = app => { | |
let backend = proxy({ | |
target: process.env.DATAROBOT_ENDPOINT, | |
changeOrigin: true, | |
}); | |
let socket = proxy('/socket.io-queue', { | |
target: process.env.DATAROBOT_ENDPOINT, | |
changeOrigin: true, | |
ws: true, | |
}); | |
app.use(socket); | |
app.use((req, res, next) => { | |
if (req.path.startsWith(process.env.PUBLIC_URL)) { | |
next(); | |
} else { | |
backend(req, res, next); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment