← Back to team overview

dhis2-devs team mailing list archive

Re: Web portal CORS/preflight problem

 

Dear Hannan,

Use $.ajax(....)


or replace crossDomain:y=true with cors:true

and try!

I have not used it but give it a try.

Alex

On Thu, Aug 27, 2015 at 1:24 PM, Jan Henrik Øverland <
janhenrik.overland@xxxxxxxxx> wrote:

> You need to do this part
>
> Ext.onReady( function() {
>   Ext.Ajax.request({
>     crossDomain: true,
>     url: base + "dhis-web-commons-security/login.action?authOnly=true",
>     method: 'POST'
>  ....
>
> with jquery instead of Ext.
>
> See the code that Morten posted.
>
> On Thu, Aug 27, 2015 at 12:19 PM, Hannan Khan <hannank@xxxxxxxxx> wrote:
>
>> Thanks Jan.
>>
>> I added <script src="//code.jquery.com/jquery-2.1.4.min.js
>> <http://code.jquery.com/jquery-2.1.4.min.js>"></script> in the <head>
>> but still I get the error. What did I do wrong?
>>
>> Regards
>>
>> Hannan
>>
>> On Thu, Aug 27, 2015 at 2:49 PM, Jan Henrik Øverland <
>> janhenrik.overland@xxxxxxxxx> wrote:
>>
>>> Hi Hannan,
>>>
>>> I have done some testing and it seems the bundled Ext version is getting
>>> old. CORS is not working well with it.
>>>
>>> We need to look at this, but for now just include
>>> https://code.jquery.com/jquery-2.1.4.min.js (minified, only 84k) and do
>>> the authentication with jquery.
>>>
>>> The good thing about CORS is that you can simply do a normal ajax
>>> request and the browser will take care of the rest.
>>>
>>> On Thu, Aug 27, 2015 at 10:37 AM, 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
>>>>
>>>>
>>>
>>
>


-- 
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 "

References