Closed frivolta closed 5 years ago
@frivolta not at all. You can have it both ways. You can use graphql for pulling data from the wordpress cms and you can make post requests back to the cms using rest. Gatsby does not mind, If you browse through the starters library and see the actual code you'll see that most of them use graphql to get data and rest to post back. Hope i could be of assistance,
Hey @frivolta,
this is exactly what I am working on.
Writing to WordPress using the REST API requires authentication of a user with the permissions. But how do we authenticate without exposing both credentials and API endpoints to the visitor?
There are some authentication plugins like JWT but it requires the login as a specific user, too. WooCommerce has a similar functionality with access tokens for WordPress users.
My plan is to proxy API requests – as stated in the linked issue – to a custom WordPress API endpoint. Authentication will happen with an API key, which is held by an environment variable. This hides both the endpoint url and authentication credentials. Post creation will happen with core WordPress functions.
Additionally, I work on a WordPress theme that complements the workflow with Gatsby and Netlify. The theme creates a post type and the corresponding endpoint to store form submissions, in the near future. Beneath other features.
In the meanwhile, if you need help with WordPress + Gatsby, feel free to ask this great community anything!
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
Thanks for being a part of the Gatsby community! 💪💜
Hey again!
It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
Summary
Hello I am sorry for the static site newbie question it is my first attempt with a static site generator. I am wondering what is the best way to manage post request from Gatsby. I would like to have a wordpress headless backend with Gatsby frontend. I will have no problems pulling data thanks to gatsby-source-wordpress, my question is about posting to the backend. For example, let's say I will have a contact form and I want to have all the incoming request stored in a custom post type, usually I will make a rest post request from the frontend. Will I have any problem with Gatsby? Does it make sense to pull data using graphql and post using rest api? Do you think another approach (like netlify) would be a better solution, I didn't considered so far as I would like a self hosted website? Thanks, F.