DHIS2 Live / Jetty v.3 / CORS

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like http://localhost:8081 for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker

···

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Hi Chase,

We have an alternative Docker project here as well with pre-built images on Dockhub as well which you also may want to check out.

Regards,

Jason

···

On Tue, Dec 19, 2017 at 6:12 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like http://localhost:8081 for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Thanks for the reply, Morten.

I’m using the App Skeleton (https://github.com/dhis2/app-skeleton ) to make calls to the API served through DHIS2 Live (with my localhost whitelisted as you showed). I’ve been thinking I need look more into ‘http-proxy’ and configure my proxy correctly and your comments may confirm that suspicion. I won’t really be running analytics as I’m just working on a concept using D2 but I think I’ll switch over to using Docker just for modernity’s sake.

Thanks!

Chase

···

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like http://localhost:8081 for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Awesome! Thanks Jason. I was unaware of this!

Chase

···

Hi Chase,

We have an alternative Docker project
here
as well with pre-built images on
Dockhub
as well which you also may want to check out.

Regards,

Jason

On Tue, Dec 19, 2017 at 6:12 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like http://localhost:8081 for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Jason P. Pickering

email: jason.p.pickering@gmail.com

tel:+46764147049

Ok, so are you successful or not? :slight_smile: Adding in frontend team just in case…

···

On Tue, Dec 19, 2017 at 10:44 PM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Awesome! Thanks Jason. I was unaware of this!

Chase

From: Jason Pickering [mailto:jason.p.pickering@gmail.com]

Sent: Tuesday, December 19, 2017 12:43 AM

To: Morten Olav Hansen morten@dhis2.org

Cc: Freeman, Chase Chase.Freeman@msi-inc.com; dhis2-devs@lists.launchpad.net

Subject: Re: [Dhis2-devs] DHIS2 Live / Jetty v.3 / CORS

Hi Chase,

We have an alternative Docker project
here
as well with pre-built images on
Dockhub
as well which you also may want to check out.

Regards,

Jason

On Tue, Dec 19, 2017 at 6:12 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like http://localhost:8081 for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Jason P. Pickering

email: jason.p.pickering@gmail.com

tel:+46764147049

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

I’ve gotten tied up with work on another project. But I will keep you informed when I give it another shot. For now this is just a “pet project” of mine in my spare time.

Though, perhaps Nicolay could try and replicate the issue using DHIS2 Live and the D2 Skeleton-app, since I believe he created it.

Thank you for following up Morten, I’ll be in touch.

Chase

···

Ok, so are you successful or not? :slight_smile: Adding in frontend team just in case…

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 10:44 PM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Awesome! Thanks Jason. I was unaware of this!

Chase

From: Jason Pickering [mailto:jason.p.pickering@gmail.com]

Sent: Tuesday, December 19, 2017 12:43 AM

To: Morten Olav Hansen morten@dhis2.org

Cc: Freeman, Chase Chase.Freeman@msi-inc.com; dhis2-devs@lists.launchpad.net

Subject: Re: [Dhis2-devs] DHIS2 Live / Jetty v.3 / CORS

Hi Chase,

We have an alternative Docker project here as well with pre-built images on Dockhub as well which you also may want to check out.

Regards,

Jason

On Tue, Dec 19, 2017 at 6:12 AM, Morten Olav Hansen morten@dhis2.org wrote:

Hi Chase

It should be possible to add localhost to the CORS whitelist in settings (I’m pretty sure the entire frontend team is doing exactly that). What are you adding to it? I think you need the full protocol host and port, so something like
http://localhost:8081
for example.

Another solution would be to setup a proxy yourself, it kinda depends on your setup… but if you are serving up your app using node, you can use one of the many the proxy libraries available for it.

If you are using something like CRA (create-react-app), it includes a proxy already and you can just map that to your DHIS2 instance.

Please be aware that the live package has some issues with analytics (unless you have mapped it to use a local postgres service), another approach could be to use dhis2-docker [1].

[1] https://github.com/dhis2/dhis2-docker

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Tue, Dec 19, 2017 at 3:09 AM, Freeman, Chase Chase.Freeman@msi-inc.com wrote:

Hi all,

I’m getting started with using the D2 library and I had intended to use the DHIS2 Live package to quickly get started in a test environment. I’ve run into some crippling CORS errors and investigated the Jetty Servlet’s web.xml file to see if I could allow for cross-origin requests. Alas, when I tried to insert the filter it would fail time no matter the configuration. Is this because it is Jetty Version 3 (as opposed to 9.4 now)? Or is there a better work around? The CORS whitelist in Access Settings is not working for Localhost.

Any tips/assistance in using DHIS2 Live to work with the D2 Library would be much appreciated.

Cheers,

Chase Freeman

Jr. Web Developer

Management Systems International

A Tetra Tech Company

Arlington, VA USA

(Work) +1 703 979 7170 x219

chase.freeman@msi-inc.com

www.msiworldwide.com


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Jason P. Pickering

email: jason.p.pickering@gmail.com

tel:+46764147049