StephenGrider / FullstackReactCode

Companion repo to https://www.udemy.com/node-with-react-fullstack-web-development
1.39k stars 1.17k forks source link

Proxy #38

Open kaiz123 opened 5 years ago

kaiz123 commented 5 years ago

The way of adding proxys has changed. It no longer has to be added to package.json, but to a file named setupProxy.js inside src of client. Also, 'http-proxy-middleware' has to be installed.

Code inside setupProxy would look like this -

const proxy = require('http-proxy-middleware')

module.exports = function(app) {
  app.use(proxy('/auth/google', { target: 'http://localhost:5000/' }))
  app.use(proxy('/api/*', { target: 'http://localhost:5000/' }))
}
ManLikeGhost commented 5 years ago

thank you very much, but do i need to require the file and can you show how file is to be required

mohannadibrahimi commented 5 years ago

Requiring the setupProxy.js file isn't necessary.