Created
May 8, 2020 02:07
-
-
Save rodrigorm/3f14c6fd42fee4edb38b37f1354397a7 to your computer and use it in GitHub Desktop.
React Native devServer proxy like webpack
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 { createProxyMiddleware } = require('http-proxy-middleware'); | |
module.exports = { | |
server: { | |
enhanceMiddleware: (metroMiddleware, server) => { | |
// console.log(middleware); | |
// console.log(server); | |
const proxyMiddleware = createProxyMiddleware('/api', { target: 'http://localhost:3000' }); | |
return (req, res, next) => { | |
console.log('middleware', req.url); | |
return proxyMiddleware(req, res, () => metroMiddleware(req, res, next)); | |
// return middleware(req, res, next); | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment