1

I am running a Drupal 8.9.2 site as a content repository accessed via an Angular 8 app. So there is one administrator who uses the Drupal interface to write content / upload files eccc.... and anonymous users view that content via the Angular app.

I have set up some views with REST Export display and have been able to pull the content in my Angular app running both backend and frontend on localhost, but when I deployed to the server problems have arisen...

all my calls fail or get canceled, this was the configuration on localhost: the Drupal website was in a folder in XAMPP/htdocs/example the views rest endpoints were like: http://localhost/example/web/api/content the Angular app was in a folder on the desktop and was served at http://localhost:4200/home now I put all the files for both backend and frontend on the root folder on the server, I also have commented this line ErrorDocument 404 /index.php in the htaccess file found in the web folder so that non existent urls are managed by the Angular app.

So the question is: What is the correct files structure in order to have the frontend at example.com/home and my Drupal site at example.com/web/admin/eccc..... (if it is possible, otherwise please suggest a better option).

3
  • there's likely more than one way to configure Apache for this setup. I'd suggest something of a host-based approach where drupal.example.com hosts your Drupal instance & angular.example.com hosts your Angular instance then have your angular app with a config variable that specifies the hostname for the API to consume.
    – Shawn Conn
    Jul 14, 2020 at 0:02
  • @ShawnConn is right, see How to Configure Multiple Sites with Apache
    – No Sssweat
    Jul 14, 2020 at 9:09
  • Thank you guys, but before buying two third-level domains from my hosting provider I would like to find another way. I found this tutorial youtube.com/watch?v=UwCX9oPpfPI&t=56s and this source code bitbucket.org/spinspire/d8-react/src/master (it is in react but I think the idea is the same) where they put the app inside the web folder. I will try and let you know, thanks
    – elenat82
    Jul 14, 2020 at 18:20

1 Answer 1

0

I solved my problem, the calls were failing due to a wrong version of PHP (you need 7.2 or higher). As for the files structure I just put all the files in the root folder, both for Drupal and Angular, it works having my Drupal site in the web folder, I don't know for other configurations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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