Cross-domain request to access WS in javascript

Cross-domain request to access WS in javascript

by Michel DENIS -
Number of replies: 2

Hi,

Please could you tell me whether, and how, do Moodle's Web Services deal with javascript requests from a cross-domain perspective (CORS or other way) ? :

- anything special to enter in the remote, client javascript code ?

- anything special to add or configure in the Moodle server and/or its Web server ?

- does one of you have an exemple of such plain javascript piece of code accessing remote Moodle web services ?

Many thanks in advance,

-michel

Average of ratings: -
In reply to Michel DENIS

Re: Cross-domain request to access WS in javascript

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Plugin developers Picture of Testers

Hi,

CORS is supported only by the REST simple server (REST protocol using tokens for authentication). I think it is supported since Moodle 3.1.

You don't have to do anything special.

You can check the Mobile app code (although is a large base code, they are standard AJAX/XHR requets using Angular http service)

Juan

In reply to Juan Leyva

Re: Cross-domain request to access WS in javascript

by Michel DENIS -

Thank you Juan, that's good news for me. I will also check the code.

Have a nice day,

-michel