Mobile app CSS / CORS Policy

Mobile app CSS / CORS Policy

Nolan Boisel -
回帖数:4

Hello guys,

I hope that i'm posting this in the right place.

As the title mention, i have a problem with customising the moodle mobile app with a CSS stylesheet. I tried to put the stylesheet in moodle/theme/mytheme/style and moodle/theme folder and added the URL to that stylesheet in the admin > mobile appearance part.

But when i go on my phone, there are no modifications at all. I tried on https://integration.apps.moodledemo.net/ and there, i saw that the stylesheet is blocked due to missing header about CORS policy.

So i then added in webservice/upload.php and webservice/lib.php those lines of code: 

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

But it still doesn't work. Can someone help me with this please

回复Nolan Boisel

Re: Mobile app CSS / CORS Policy

Noel De Martin -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi there,

It should work on integration.apps.moodledemo.net, if you are having some problems with CORS make sure to check out the Using the Moodle App in a browser page.

Also, you may already be aware of this, but just in case keep in mind that this will not work in the application you can find in the appstores if you haven't purchased a Moodle App plan.

回复Noel De Martin

Re: Mobile app CSS / CORS Policy

Nolan Boisel -
Hello Noel,

Thank you for your reply !

Oh okay, so the CORS policy problem is just because i try the app on a browser, but if i can't customise the app it's because i didn't purchase a Moodle App Plan. ( Since the app i tried on my phone is indeed from the Google play store ).

Well i wasn't aware of this, i think i read the wrong doc (https://docs.moodle.org/dev/Moodle_App_Customization instead of https://docs.moodle.org/dev/Moodle_App_Remote_Themes which state this in the first lines).
回复Nolan Boisel

Re: Mobile app CSS / CORS Policy

Noel De Martin -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

We're in the process of updating the docs and just now I added this in that first document as well, sorry for the confusion.