DEV Community

Discussion on: Headless WordPress with React

Collapse
 
timothymehlhorn profile image
Tim Mehlhorn

I am been doing something very similar with Polymer and Wordpress. Restricting the Wordpress CMS to just content has been having huge performance impacts for some of my projects.

Collapse
 
bennerge profile image
BennerGe

How did you do the authentication and how did you bring the nonces into your Polymer app?
I am working on also with Polymer and Wordpress but I have no idea how I can get the nonce into my app.

Collapse
 
jchiatt profile image
J.C. Hiatt

Hey! From the Codex:

For developers making manual Ajax requests, the nonce will need to be passed with each request. The API uses nonces with the action set to wp_rest. These can then be passed to the API via the _wpnonce data parameter (either POST data or in the query for GET requests), or via the X-WP-Nonce header.

More here: developer.wordpress.org/rest-api/u...

Thread Thread
 
bennerge profile image
BennerGe

Yes I read that already, had already tested it and it works. But I wonder how I can pass the generated nonce from WP to my app, if it is completely independent from my Wordpress installation, e.g. the app is in a different directory / subdomain as Wordpress.

Thread Thread
 
jchiatt profile image
J.C. Hiatt

That's a good question! I'll look into that and see if I can write a post on it.

—J