Connect React App with DHIS2

Hi

I am trying to connect a React App with local DHIS2 Instance.
In the server URL when I use “http://localhost:9494/dhishome” the application works fine, But when I use “http://127.0.0.1:9494/dhishome” then it gives me the following error message.
127.0.0.1 is also a localhost

Any suggestion is much appreciated.

Thanks

image

Hi @sami12111

Is this URL added to the CORS whitelist access settings in the System Settings app?

Thanks!

2 Likes

Hi @Gassim

Yes I have added URL in the CORS setting (screenshot attached).
I have a react application running on http://localhost:3000

image

Thanks

1 Like

For me it’s not clear why you’re getting that issue but are you able to login from the browser using http://127.0.0.1:9494/dhishome in the first place and the error only appears when you try to use the app? Thanks!

Hi @Gassim

Yes, when I access the DHIS-2 instance using http://127.0.0.1:9494/dhishome it works fine. But when I try to connect a new React app with DHIS-2 instance I got the above Error.
In the server URL I put http://127.0.0.1:9494/dhishome.
In the user name and password I put my credentials.

Thanks

I’m not sure why this would happen! Why is it important that you use 127.0.0.1 instead of localhost?

Thanks!