Skip to content
Discussions/App Development/Cors issue on React AppForum ↗

Cors issue on React App

App Development5 posts386 viewsLast activity Jun 2023
TE
Teja_SatyaOP
Jun 2023

Hi Team,
i am running
DAML Json-API on localhost:7575 and
my react App on localhost:3001

I am able to get the responses from Json-API using postman
but while hitting the same url (‘http://localhost:7575/v1/query’) with react i am getting CORS issue

please find the below Screenshot and help me resolving this issue

Thanks in advance :slight_smile:

RO
rohitt
Jun 2023

Hi @Teja_Satya

I suspect this is due to your browser blocking these requests as it does not comply with Same-origin policy .
Specifically, your UI is running on localhost:3001 while you have the JSON API running on localhost:7575 . Browsers will block these requests by default as a security measure.

RO
rohitt
Jun 2023

To remedy this consider using something like NGINX as a reverse proxy to make sure that your UI and the JSON API run on the same host and port or a webpack proxy as mentioned in this example.

TE
Teja_Satya
Jun 2023

Hi Rohitt,

we are using the same setupProxy.js( which is used by navigator )in my react app but still we are getting the CORS error,

I don’t understand how navigator is working fine but not our application which almost do the same job ,

please clarify :slight_smile:

GA
Gary_Verhaegen
Jun 2023

Having the proxy there doesn’t necessarily mean your app is going through it - make sure your calls to the JSON API from your application’s code use the proxy origin rather than trying to connect directly to the JSON API origin (typically, check that your app does not use the JSON API port explicitly).

← Back to Discussions