← Back to team overview

dhis2-devs team mailing list archive

Re: Web portal CORS/preflight problem

 

Hi Hannan

I haven't used the portal plugins (maybe Jan can help there), but what I
did when I implemented CORS for DHIS 2, was to simply test using this:

$.ajax({
  url: 'some-web-api-url.json',
  headers: { "Authorization": btoa('admin:district' }
}).done(...);

Also remember that there must be a 100% match between where your request is
coming from, and what is in the whitelist, this also means that you must
make the request from a http server, you can't make just a index.html file
and open it in a browser.

You can also enable a bit more debug output from your server by finding the
file in web-commons called log4j.properties (in your unpacked WAR file) and
add this line to the end:

log4j.logger.org.hisp.dhis.security.filter = DEBUG


--
Morten

On Thu, Aug 27, 2015 at 3:37 PM, Hannan Khan <hannank@xxxxxxxxx> wrote:

> Dear Alex
>
> Thank you for sharing the resources. but the problem still persists. i
> write as following:
>
> Ext.onReady( function() {
>   Ext.Ajax.request({
>     crossDomain: true,
>     url: base + "dhis-web-commons-security/login.action?authOnly=true",
>     method: 'POST',
>
> Please check.
>
> Regards
>
> Hannan
>
> On Thu, Aug 27, 2015 at 1:00 PM, Alex Tumwesigye <atumwesigye@xxxxxxxxx>
> wrote:
>
>> Dear Khan,
>>
>> Look at this
>> http://api.jquery.com/jquery.ajax/
>> Read about crossDomain, by default it set to false so you may need to set
>> it to true.
>>
>> Ideally, in your ajax request, add crossDomain:true
>>
>> Alex
>>
>>
>>
>> On Thu, Aug 27, 2015 at 9:53 AM, Mark Polak <markpo@xxxxxxxxxx> wrote:
>>
>>> Hello Hanna,
>>>
>>> Did you add http:// (or https:// if you use a secure line) in front of
>>> the IP address?
>>>
>>> On the demo instance this is a bit confusing as the examples do not show
>>> that but it is required for it to work correctly.
>>>
>>> Regards,
>>>
>>> Mark
>>> ________________________________________
>>> From: Dhis2-devs [dhis2-devs-bounces+markpo=
>>> ifi.uio.no@xxxxxxxxxxxxxxxxxxx] on behalf of Hannan Khan [
>>> hannank@xxxxxxxxx]
>>> Sent: 27 August 2015 08:29
>>> To: DHIS 2 developers
>>> Subject: [Dhis2-devs] Web portal CORS/preflight problem
>>>
>>> Dear Experts
>>>
>>> I am facing problem to creating Web Portal, facing problem CORS.
>>> First I try portal from 103.247.238.68 not working and then put this
>>> address in the white list of the dhis2 server at 103.247.238.68:8080<
>>> http://103.247.238.68:8080>. But but still having the same problem the
>>> error message is 'which is disallowed for cross-origin requests that
>>> require preflight'.
>>>
>>> Now how I resolve this? The script is similar as on the developer guide,
>>> page 49.
>>>
>>> Please advice.
>>>
>>> Regards
>>>
>>> Hannan
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>
>>
>>
>> --
>> Alex Tumwesigye
>>
>> Technical Advisor - DHIS2 (Consultant),
>> Ministry of Health/AFENET
>> Kampala
>> Uganda
>>
>> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
>>
>> IT Specialist (Servers, Networks and Security, Health Information Systems
>> - DHIS2 ) & Solar Consultant
>>
>> +256 774149 775, + 256 759 800161
>>
>> "I don't want to be anything other than what I have been - one tree hill "
>>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References