I want to disable the front-end access of my headless Drupal site, that is just a REST API for a Vue site.

Except for the login page, there is no need to access any node, taxonomy or view directly as everything is delivered via REST.

How can I achieve this?

  • 2
    I suppose two ways to do it would be add Rabbit Hole module or disable "access content" permission from anonymous users. If you are using ACL on a headless site, the latter may be problematic. – Kevin Oct 26 '18 at 21:18
  • 1
    So basically you want a redirect from everywhere to /user, no? – leymannx Oct 27 '18 at 18:20
  • 3
    nope... just for not logged in users. Logged in users should be able to access the backend (Admin Interface). Is there no workflow to follow? I don't think I am the first person that uses Drupal in an headless manor. Really the question is... how to decouple Drupal from it's frontend (not drupal admin) as alle the nodes, taxonomies and views are served via rest. – mogio Oct 27 '18 at 21:26
  • 1
    Did you find a solution to that? I am trying to achieve exactly the same... – MrUpsidown Dec 5 '18 at 15:32
  • 1
    I think it will take a direction similar to Kevins solution. I was not able to find any best practice nor guide. – mogio Dec 12 '18 at 7:02

Based on your responses in the comments, it sounds like you want anonymous users to be sent to the login page on any access and for authenticated users to be able to access the site as normal. You can achieve this with a custom module that checks for logged-in status and redirect to the login page, or via the Require Login Module which does essentially the same thing.


You can use the following module.

Anonymous login

Use-case examples

1) You want to restrict your entire site to authenticated users. Simply enter "*" as the only path to redirect and all anonymous traffic will be redirected to the login page.

2) Your website sends out emails that contain links that only authenticated users can reach (edit your account, edit a node, view a private message, etc). If the user clicks the link from the email and they are not currently logged in they will reach an "Access denied" page; which is horrible for usability. With this module enabled and configured to act on node/*/edit paths, if a user clicks a link to site.com/node/123/edit, they will be redirected to site.com/user/login?destination=node/123/edit, so they can log in, then be brought to the page originally requested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.