Skip to content

Not allowed to view drafts #300

@swif-nl

Description

@swif-nl

I am building a headless Wordpress website (VueJS). Data is loaded via the REST API.

Now, I need to enable the preview-functionality. I installed this plugin. When I hit the preview button in Wordpress it opens a new tab for the specific page and adds these params to the URL:
?preview_id=11&preview_nonce=d778b8981f&preview=true&acf_format=standard

I add these params to the URL for the REST API call to retrieve the page-data.

Default:
http://localhost:8888/wp-json/wp/v2/pages/13

Draft:
http://localhost:8888/wp-json/wp/v2/pages/13?preview_id=11&preview_nonce=d778b8981f&preview=true&acf_format=standard

Of course, I need some authorization to be able to load the draft version. In order to do that I can successfully request a JWT token and add this to the draft-page request. However, the response I get tells me "you are not allowed to preview drafts". The response is a HTML error page, and not a JSON response as I would expect.

When I test a (no-draft) request in Postman, I add the JWT authorization token and the API returns the requested data. When I change a character in the JWT token it returns a JWT error. So I know my JWT token is valid and recognized by Wordpress.

What could be the cause of this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions