XMLHttpRequest cannot load https://www..... disallowed for cross-origin request ...

8,108 views
Skip to first unread message

weheh

unread,
Dec 14, 2013, 10:39:25 AM12/14/13
to web...@googlegroups.com
I've got a dialog that I pop open and on it is a button that makes a web2py_component call. The button code looks like this, after it's gone through the XML() helper and jquery UI.

<button class="..." onclick="if (confirm('Read?')) { web2py_component(&quot;https://www.mysite.com/mycontroller/myfunc.load?pc=YGYzlEh6&amp;_signature=607e035a239d88bd3ab8652814ceff2a9cab92b5&quot;, &quot;target-div&quot;); }" role="button" aria-disabled="false"> ... </button>

The button works fine when I launch it from my development machine: http://127.0.0.1:8000/myapp/...  But, when I migrate the code to the server and execute there, I get an error.

Firebug reports the following:

XMLHttpRequest cannot load https://www.mysite.com/mycontroller/myfunc.load?pc=YGYzlEh6&_signature=607e035a239d88bd3ab8652814ceff2a9cab92b5. The request was redirected to 'https://www.mysite.com/user/login.load?_next=/mycontroller/myfunc.load%pc=YGYzlEh6', which is disallowed for cross-origin requests that require preflight.


Anybody have any idea how to deal with this?


Anthony

unread,
Dec 14, 2013, 12:13:55 PM12/14/13
to web...@googlegroups.com
Is it in fact a cross-origin request, and have you set up CORS on the server?

weheh

unread,
Dec 14, 2013, 12:33:21 PM12/14/13
to web...@googlegroups.com
Thanks, Anthony. Wasn't sure I had to go down that path. Yet another acronym to hide under the rug.

weheh

unread,
Dec 16, 2013, 8:38:17 AM12/16/13
to web...@googlegroups.com
Hi Anthony, I added CORS stuff to my Apache httpd.conf as per this http://enable-cors.org/server_apache.html but I'm still getting the same error message. Any ideas about how to push through this?

Anthony

unread,
Dec 16, 2013, 9:16:40 AM12/16/13
to web...@googlegroups.com
I don't know. Does it happen in all browsers?

weheh

unread,
Dec 16, 2013, 9:42:42 AM12/16/13
to web...@googlegroups.com
Yah, I see it on other browsers: "Redirects are not allowed for CORS preflight requests." and then "XMLHttpRequest: Network Error 0x8007005, Access is denied."

Marin Pranjić

unread,
Dec 16, 2013, 9:45:45 AM12/16/13
to web2py-users
@weheh can you try a custom jQuery.ajax cross domain call for testing/debugging? (just load something from HTTP to HTTPS)

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

weheh

unread,
Dec 16, 2013, 10:12:22 AM12/16/13
to web...@googlegroups.com
@Marin: Thanks for your suggestion. I believe that that is precisely what is causing this issue. The original call is an HTTP call. It's followed by an HTTPS that results in the error message. But still no idea how to get the https call to go through.

Marin Pranjić

unread,
Dec 16, 2013, 10:16:05 AM12/16/13
to web2py-users
Well, as I said, try your own jquery.ajax call.

If it works, then CORS is enabled but component load is failing.
If it doesn't work, then you didn't enable CORS correctly.

You should also try $.ajax({crossDomain: true, ...});
JQuery should add it automatically but maybe it's not detecting it properly.

weheh

unread,
Dec 18, 2013, 6:06:14 AM12/18/13
to
Looks like I got it working. The Apache config file wasn't complete, so once I found that issue, the CORS started to function properly. Thanks again for your responses.

Umed

unread,
Feb 11, 2014, 1:52:59 AM2/11/14
to web...@googlegroups.com
why didnt you specify what was a solution 


On Wednesday, December 18, 2013 4:05:43 PM UTC+5, weheh wrote:
Looks like I got it working. The Apache config file wasn't complete, so once I found that issue, the CORS started to function properly. Thanks again for your responses.

Marin Pranjić

unread,
Feb 14, 2014, 9:46:46 AM2/14/14
to web2py-users
Reply all
Reply to author
Forward
0 new messages