Authentication with Passport + Facebook + Express + create-react-app + React-Router + proxy Authentication with Passport + Facebook + Express + create-react-app + React-Router + proxy express express

Authentication with Passport + Facebook + Express + create-react-app + React-Router + proxy


I was also running into this issue - changing the CRA proxy config seemed to do the trick:

"proxy": {   "/api": {      "target": "http://localhost:3001/"   }}

Where the OAuth link is located at /api/auth/foo, CRA app is at localhost:3000, and the express app is at localhost:3001


I ran into the same problem today and solved it by not using create-react-app's proxy, but instead setting up a proxy in my backend to the create-react-app.

At the end of my express app, I have

 // all routes above if (env.isDevelopment()) {   const proxy = require('express-http-proxy')   app.use('/*', proxy('http://localhost:3000')) } else {   // probably serve up build version in production }

Just remember to turn off the proxy in the package json of your client, or else you could end up with an infinite proxy loop or something.


EDIT: My previous answer had nothing to do with the issue and did not solve it. The whole thing in my case was caused by the registerServiceWorker in CLI generated index.js. Just remove it and everything works like it should.

//Remove this lines from index.jsimport registerServiceWorker from './registerServiceWorker'registerServiceWorker();