Error: Add the URL of your WordPress REST API in state.source.api

Hi there, I’m totally first-time trying frontity and I’m totally thrilled and I want work to with my local installation of WordPress but, I’m having a really bad time as I’m not able to connect with api and I get this error Add the URL of your WordPress REST API in state.source.api. in console–full error below. On address http://localhost:3000 I see “Internal Server Error.” But I’ve added api link in frontity.settings.js file like:

state: {
      source: {
          api: "localhost/wordpress/wp-json"
      }
}

What’s wrong happening IDK? I tried to change to Permalinks in WP setting and tried al l but still not working. But the API works fine in browser and postman which means problem isn’t with WP. Check my shell log at: https://asciinema.org/a/qc7GyEU3LGlxqxOaPIe6CdbQP

Hi @inamkbmail,
Try changing the api URL in settings to start with http,
http://localhost/wordpress/wp-json

3 Likes

Thanks for the solution!

Hey @inamkbmail welcome to Frontity!

I’m curious about what you are building with Frontity, can you share something?

Please let us know if there’s anything that you need, we love to hear feedback from people using Frontity for the first time to improve our framework and docs :slight_smile:

1 Like

Thanks for asking. But right now I’m just testing and learning… I fond frontity super cool maybe I want to make blog with it. Can I just ask you if you’ve any experience that wordpress.com free plan offer API use? If yes how can I access them? Nice idea would be to make a tutorial blog/video…
TY! :heart_eyes:

Hey @inamkbmail! :wave:

Sure, you can use wordpress.com with frontity! You just need to point frontity to the relevant endpoint as described in the docs

So, in your case, it should be something like https://public-api.wordpress.com/wp/v2/sites/site.wordpress.com where site is the name of your site.

Hope this helps! :slightly_smiling_face:

2 Likes

I’m totally inspired with frontity now. I just have to enter API address and it works… :star_struck: Wondering why I don’t have to authorize it or etc… But is this safe? Not everyone can steal data?

1 Like

Hey @inamkbmail the API you are accessing is only exposing the public data of your site, which in the end is the same data that is available in the content. Consider it just a different way to access your content, instead of HTML your WordPress is exposing it in a JSON which is easier to process.

Yes, I understand it but this isn’t the same way like anyone could grab someone data and display it on his web. Suppose I fetch someone copyright data and use it easily. But that’s not a problem till now.
But what if I’ve to keep some data private or some pages accessible for certain people?

Thanks BTW, today I spent hours with frontity and looks great. TY! I’ll be in touch with here.

2 Likes

Yes, I understand it but this isn’t the same way like anyone could grab someone data and display it on his web. Suppose I fetch someone copyright data and use it easily.

As long as the data is public you could scrap it and post it anywhere else without an API.

But what if I’ve to keep some data private or some pages accessible for certain people?

Then you would need to make those parts private, and not expose them in the public API. And also to implement an authentication system. So you’ll be forced to use a wp.org instance instead of a wp.com so you can customise the REST API response.

Great! Keep us posted and let us know your impressions :blush: