Hey there, I’ve seen many people talking about 404 error they run into when connecting their own Wordpress site and I tried to solve my problem, but so far with no luck.
Seems to happen to every page, although they are existing on my Wordpress site.
If I don’t specify the homepage in frontity.settings.js for @frontity/wp-source, it doesn’t throw an error, but then it fetches only the archived posts.
Can’t exactly figure out what causes it, but it’s weird as when I enter in url “/home” or “/test-page” which are existing pages on the Wordpress side, I can see this content at frontity.state.source.
Okay, so apparently Frontity didn’t like that my Wordpress folder starts with a capital letter. Once I changed it, the error went away and state.router.link shows me the right info about every page. It’s a bit confusing as I have another Frontity project where the Wordpress folder starts with a capital letter as well and no issues came up there, so I didn’t even think at first that could be a problem. I’ll just leave it here in case someone stumbles upon the same problem.
Glad you were able to solve your issue.
By “WordPress folder” do you mean the folder name in the file system? If it’s that, I don’t know what could be going on there.
Yes, it was exactly that I changed it from a capital R to r and it worked.
What was weird about it that when I checked frontity.state.source with an existing error, it was retrieving some data from API, so I’m not sure how it works.
However, I would be also interested to see the other project that you mentioned where the incorrect casing did work. Maybe there is some inconsistency in how Frontity treats those URLs
Not a typo, at that moment I had it called https://aivars.dk/admin.Rounda/wp-json in both - frontity.settings file and the URL itself, then I changed the URL (Wordpress folder) to admin.rounda and the same for settings file, and it worked.
This is another project I’m doing with Frontity and it works with capitalised folder name.
All right, I see but on the https://agne-portfolio.vercel site the state.source.api is (correctly) https://aivars.dk/admin.AgnePortfolio/wp-json
So, as far as I can tell, everything works correctly because if you try to go to https://aivars.dk/admin.agnePortfolio/wp-json (lowercase a), this link does not return anything. So I think that the issue that you saw did not have anything to do with Frontity.
Hmm, I think that this could not have worked. As far as I can tell, you have exactly match the casing of the URL of your REST API:
When the URL at state.source.url contains a capital letter (properly written according to the project’s name/folder) and in combination with state.source.homepage, every call to the website returns a 404 error.
If you get an error when accessing your REST AP i (like in this case → https://aivars.dk/admin.Rounda/wp-json) this is something that doesn’t really have to do with Frontity but with the Wordpress installation
In order to work with Frontity you have to first assure you can access the REST API of your Wordpress
If you think the problem is somewhere else, can you please provide a repo or code-sandbox with your code? This is especially helpful to find solutions of technical issues with specific code
As setting the state.source.homepage overrides the / route, you should set state.source.postsPage as well in order to be able to access the posts archive in a different route.