islamic-network / api.aladhan.com

The AlAdhan API
GNU General Public License v3.0
118 stars 30 forks source link

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource using Javascript. #70

Closed iamjenechka closed 3 months ago

iamjenechka commented 4 months ago

السلام عليكم‎‎.

Would you, please, help me?

My site is: http://salyat.com/converter/

here's a code: https://gist.github.com/iamjenechka/73dcc438482d5ab6996cf136cc6f4829

and I got:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.aladhan.com/gToH?date=04-02-2024

meezaan commented 4 months ago

That's not the error I get. Here's a screenshot of what I'm seeing:

image

So you're basically calling an incorrect URL.

meezaan commented 4 months ago

And the code shows http, so how can the error be https?

iamjenechka commented 4 months ago

Because code that I sent you before differs from the code on the site now.

When I was waiting for your answer yesterday I tried cors proxy.

If I'll revert the code to the gist which I sent you yesterday the issue will be about cross-origin request blocked.

I'll be online in a few hours and revert the changes! Please wait for it. Thank you!

iamjenechka commented 4 months ago

@meezaan! The changes has been reversed to https://github.com/islamic-network/api.aladhan.com/issues/70#issue-2136856832

please try again from a browser's private window

it's seems it's about CORS request blocking..on the remote side.

Screenshot_2024-02-16_11-48-13

meezaan commented 4 months ago

@meezaan! The changes has been reversed to https://github.com/islamic-network/api.aladhan.com/issues/70#issue-2136856832

please try again from a browser's private window

it's seems it's about CORS request blocking..on the remote side.

Screenshot_2024-02-16_11-48-13

Sorry I have not had a chance to have a look, but from the screenshot alone if you are calling an http url from an https domain the browser will block your call.

There is no CORS header issue on the api - all the headers are in the code base in the git repo at html/index.php.

iamjenechka commented 4 months ago

I already tried https requests as well. Will send you a screenshot as Monday.

meezaan commented 4 months ago

I already tried https requests as well. Will send you a screenshot as Monday.

Sorry I am just getting to this. I still see the call being made is http and I'm quite sure that is the problem.