0

I have a react app served on http://localhost:3000. I also have a kdb+ server on http://localhost:8080. I send HTTP request to the kdb+ to get data from the DB and because of CORS I added a proxy in the react app package.json file.

The problem is, that because I call the kdb+ server from http://localhost:8080/?getData (without relative paths) and because when I call the kdb+ server inside the app I use fetch('/?getData') (as described in this answer) react "knows" this url so it doesn't use the proxy.

How can I solve this?

Is there a way to set react to work only on http://localhost:3000/somepath? I tried setting the homepage parameter in the package.json file and the app worked both on / and /somepath.

Maybe the solution is to set kdb+ to listen on http://localhost:8080/sompath? I searched for it and couldn't find a way to do that.

orr
  • 129
  • 10
  • Does this answer your question? [Proxy in package.json not affecting fetch request](https://stackoverflow.com/questions/44365577/proxy-in-package-json-not-affecting-fetch-request) – Harald Gliebe Jul 25 '21 at 17:53
  • @HaraldGliebe No because I don't know how to enable CORS in the kdb server. and the second approach doesn't seem related, and if it does, I didn't understand how. – orr Jul 25 '21 at 18:21

0 Answers0