Support » Developing with WordPress » WordPress API – CORS Error

  • Resolved lucasctd

    (@lucasctd)


    Hi there,

    I am trying to request data from WordPress themes and plugins api, but I am always getting CORS errors as response :v

    I used the query below on postman and it worked, but on my website it does not work:

    https://api.wordpress.org/themes/info/1.1?action=query_themes&request[search]=Twenty Twenty-One&request[fields][downloadlink]=1&request[fields][downloaded]=0&request[fields][screenshot_url]=1&request[fields][rating]=0&request[fields][num_ratings]=0&request[fields][homepage]=0&request[fields][description]=0&request[fields][author]=0

    I am making the request on the website below:

    https://wptemplatebuilder.ssaweb.solutions/2021/02/07/hello-world/

    Link to the API: https://codex.wordpress.org/WordPress.org_API#Themes

    If you go to your browser’s console, you’ll see the error there.

    Am I missing something?

    Thanks in Advance.

    • This topic was modified 2 years, 1 month ago by lucasctd.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter lucasctd

    (@lucasctd)

    I have figured out what’s going on. Jesus, it’s all about a forward slash.

    If you use:

    https://api.wordpress.org/themes/info/1.1?action=query_themes
    it will return CORS errors,

    but if you do:

    https://api.wordpress.org/themes/info/1.1/?action=query_themes

    (see the forward slash after number 1)

    It works…

    • This reply was modified 2 years, 1 month ago by lucasctd.
    Moderator bcworkz

    (@bcworkz)

    Good catch! FWIW, all WP permalinks like to have trailing slashes. While it often accommodates requests without it, as you’ve found, there are cases where it is required. Even when a link without the trailing slash works as expected, you’ll find WP will do a 302 redirect just to add the slash. Better to include it in the first place 🙂

    Thread Starter lucasctd

    (@lucasctd)

    @bcworkz do you know if there is any limit to access wordpress.org api? I don’t see it anywhere, but I am pretty sure it’s not unlimited xD

    Moderator bcworkz

    (@bcworkz)

    Sorry I don’t know. My guess is it is not limited, but if it’s abused to the point someone notices server issues, there will be a manual intervention. As in DDoS level abuse. I doubt anyone using it respectfully would ever have an issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress API – CORS Error’ is closed to new replies.