FullstackReactCode icon indicating copy to clipboard operation
FullstackReactCode copied to clipboard

Proxy

Open kaiz123 opened this issue 7 years ago • 2 comments

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/' }))
}

kaiz123 avatar Oct 26 '18 10:10 kaiz123

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

ManLikeGhost avatar Dec 13 '18 08:12 ManLikeGhost

Requiring the setupProxy.js file isn't necessary.

mohannadibrahimi avatar Dec 18 '18 09:12 mohannadibrahimi