Skip to content

Instantly share code, notes, and snippets.

@asamountain
Last active January 1, 2020 12:58
Show Gist options
  • Save asamountain/6de6e5d3cb70bfab7feade2f588ecba6 to your computer and use it in GitHub Desktop.
Save asamountain/6de6e5d3cb70bfab7feade2f588ecba6 to your computer and use it in GitHub Desktop.
When React proxy in package.json doesn't work, use 'http-proxy-middleware'
const proxy = require('http-proxy-middleware');
module.exports = function (app) {
app.use(proxy('/search', {target: 'http://localhost:8000/'}));
}
@asamountain
Copy link
Author

asamountain commented Jan 1, 2020

  1. npm i http-proxy-middleware
  2. make above file in src folder
  3. specifies proxy(/targetUrl, {target:http://localhost:port`})`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment