islamic-network / aladhan.com

The AlAdhan.com website and app
https://aladhan.com
GNU General Public License v3.0
50 stars 19 forks source link

Blocked CORS in Chrome Extension #26

Closed shahednasser closed 2 years ago

shahednasser commented 2 years ago

I have a Chrome Extension called Quran In a New Tab and I've been using this API for a while. However, recently all requests are blocked with the following error:

Access to XMLHttpRequest at 'http://api.aladhan.com/v1/hToG?date=27-5-1443' from origin 'chrome-extension://fdhiopcnpihkmbkfagjdibggbaangnjp' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

If it's possible to fix this issue it would be of great help. Thank you.

meezaan commented 2 years ago

Salaam @shahednasser. This is not related to the API - nothing has changed on the headers.

This is likely because the extension makes an XMLHttpRequest over http. If you use https it should work just fine.

shahednasser commented 2 years ago

The requests are made from chrome:// as that where extensions run from and I can't control it. Is it possible to add an exception for that?

meezaan commented 2 years ago

It's not just where the request is made from what the target URL is. Use https://api.aladhan.com/v1/hToG?date=27-5-1443 instead of http://api.aladhan.com/v1/hToG?date=27-5-1443.

shahednasser commented 2 years ago

I'll try that. Thank you.