0

I use fetch('htp://list-of-servers') that returns a list of urls

  • test1.example.com
  • test3.example.com
  • test5.example.com

Then I need to perform a fetch() on each one of these urls: fetch('test1.example.com').then(...)

urls.map(url => fetch(url))

but

  • a) url is not cors enabled (so I tried adding them in setupProxy)
  • b) I don't know these urls in advance (since they're result of an earlier fetch, so I'm not sure how they can be added to setupProxy.js. I basically need some kind of equivalent to curl, that can request any non-cors remote url, but in js/react/node.

Suggestions?

Noon Time
  • 976
  • 7
  • 17

1 Answers1

0

Found a solution online. I have to run an express server/node app at the same time as the react client (different port), so client requests to url=test1.example.com, would be written as fetch(`/api/${url}`) then that would hit the express server localhost for proxying, where it would do a non-browser server-side request fetch(`http://${url}`) where cors problems wouldn't be an issue. I needed an ELI5.

Noon Time
  • 976
  • 7
  • 17