How to prevent drafts from being served (single content)

System Information
  • Strapi Version: 4.6.0:
  • Operating System: Windows 10:
  • Database: Postgres:
  • Node Version: 18.13.0:
  • NPM Version: 8.19.3:
  • Yarn Version: 1.22.19:

Hey, does anyone know if there is a way to prevent strapi from serving drafts for single content pages? For example if my article with id=33 is a draft, I want /api/articles/33 to return a NotFoundError instead of the article.

I know there is " publicationState=live (which is the default anyway) for the collecion api. But it doesn’t do anything for single items.

If there is no way, is there any way to check if the article is a draft from the api?

Thanks,
Simon

Found a way - the publishedAt field in the response is null when it’s a draft.

1 Like