Home > other >  why api calls are not working in git hub page
why api calls are not working in git hub page

Time:09-05

I just finish my news site and while running in localhost of vs code, its working perfectly but on hosting in gh- page api is not working. here is the link of my repository:- https://github.com/Ankitsahu640/Express-Time-News

and here is link of hosted gh-page:- https://ankitsahu640.github.io/Express-Time-News/

that's how my site seen in local host of vs code

CodePudding user response:

I tried to replicate your code and I realized the third party api you are sending request to https://newsapi.org/v2/top-headlines?country=in&apiKey=dbddeef57b58421aafd6a26534fd9d8d

Does not allow you to send request from broswer except from localhost, thats why it works on your local machine.

Here the complete response:

{
    status: "error",
    code: "corsNotAllowed",
    message: "Requests from the browser are not allowed on the Developer plan, except from localhost."
}
  • Related