Cant run a dhis2 web app

I have been trying to develop a dhis2 application, but i am using the play instance and have not set it up locally

This is my .env file
REACT_APP_DHIS2_BASE_URL=“http://localhost:8080

REACT_APP_DHIS2_USERNAME=“admin”

REACT_APP_DHIS2_PASSWORD=“district”

DHIS2_PROXY=Login app | DHIS2

and i have tried running the app with a proxy yarn start --proxy Login app | DHIS2

But whenever i try to log in with admin and district, i get this error

I have been trying to develop a dhis2 application, but i am using the play instance and have not set it up locally

This is my .env file
REACT_APP_DHIS2_BASE_URL=“http://localhost:8080

REACT_APP_DHIS2_USERNAME=“admin”

REACT_APP_DHIS2_PASSWORD=“district”

DHIS2_PROXY=Login app | DHIS2

and i have tried running the app with a proxy yarn start --proxy Login app | DHIS2

But whenever i try to log in with admin and district, i get this error

image

Add http://localhost:3000 to the Access CORS whitelist in System settings.

1 Like

Hi @AK1239 . Thanks for the question and welcome to the DHIS2 Community of Practice! And welcome particularly to our development corner!

Local instance

First, we’d encourage you to set up a local DHIS2 instance for app development as this will be more stable (our play instances are reset regularly and are used by many people). There are currently a couple of options for spinning up a locale instance with docker:

Currently, you can proxy the play instances, but this may be restricted in the future. This instance is used by many people, so it’s not suited for heavy development tasks/modifications.

Local environment variables

In general, we discourage use of environment variables as they shouldn’t be necessary (e.g. the base url will be persisted after you login once in your app). Other values like proxy can be passed as command line arguments. Please refer to the list of supported values: Environment Variables | DHIS2 Developer Portal.

Running with proxy

The above said, you should be able to run with the proxy, e.g. if you remove the environment variables,

  1. Make sure the port you’re running the app on (e.g. 3000) is added to the allowlist under settings (as @ulanbek pointed out :pray:)

  1. you can now run yarn start --proxy https://play.im.dhis2.org/stable-2-41-0-1 --proxyPort 8082 (I’m going to run on port 8082, because I have something else running on 8080) (documentation: Proxy | DHIS2 Developer Portal)
  2. check that the proxy is running by visiting http://localhost:8082/dhis-web-login/ (you may need to refresh this once or twice to get it to load) (there’s a bug with our proxy right now, so visiting http://localhost:8082 will insert a unnecessary stable-2-41-0-1 in the context path), and log in
  3. visit your app and enter the server (http://localhost:8082) and authentication (e.g. admin/district):
  4. your app should now be connected

Let us know if you have any difficulties. And again we’d encourage you to set up a local instance for development. Let us know if we can provide any help with that.