I set up a Drupal 8 CMS at http://mydrupalsite.com/.I successfully created a RESTFul API at http://mydrupalsite.com/api/v1/newsarticles. My API pulls content by doing something like

$query = \Drupal::entityQuery('node')
    ->condition('type', 'newsarticles')
    ->condition('status', NODE_PUBLISHED)
    ->range(0, 1);

However, I noticed that I can still see content at http://mydrupalsite.com/node/<integer>. What's the best way for my headless CMS to NOT expose content other than to:

  • administrators who need to edit the content
  • expose content only via the API end points
  • Disallow access? – Kevin Apr 6 '18 at 21:21
  • Can you elaborate? You mean through robots text file? Or htaccess? If htaccess, how do you allow administrators to still view it so that they can edit it? – John Apr 7 '18 at 0:50
  • 1
    If you want editors to be able to edit it through a browser, then it's not headless. – Jaypan Apr 7 '18 at 3:55
  • I tried adding the rule Redirect 301 /node/(\d+) /node/$1/edit?destination=/admin/content to my .htaccess but it doesn't seem to take any effect. Any idea what's wrong with it? – John Apr 7 '18 at 4:06
  • @Jaypan ok I change my requirement. I don't want administrators to go to /node/(\d+), but I still want them to be able to easily click to the CMS page that allows them to edit the node. Right now, the first column in the table of the page /admin/content has links that take you to /node/(\d+). – John Apr 7 '18 at 4:08

Your Answer

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

Browse other questions tagged or ask your own question.