Skip to content

Debugging common errors with Next.js and Drupal integration

Lauri Eskola edited this page Jul 27, 2022 · 3 revisions

Content model mismatch

The content model of the basic starter is designed to work with Acquia CMS with its default content model. Installing Acquia CMS with the content model to ensures that the backend has all the content that the Next.js site uses.

If you prefer to install Acquia CMS without the default content model, or you want to modify the content model, you'll have to modify CONTENT_TYPES in [...slug].tsx to match the content model in the Acquia CMS backend.

Incompatible web server setup or incorrect environment variables generated

Ensure that you have configured environment variables correctly. This can be tested by making a GET request to [NEXT_PUBLIC_DRUPAL_BASE_URL]/jsonapi. To get the most accurate results, it is recommended to make a request from the container where the Next.js app is hosted to make sure that network connection and authentication more closely resemble the Next.js app. This could be done with curl -v [NEXT_PUBLIC_DRUPAL_BASE_URL]/jsonapi for example.

If you are not getting a valid response, the error is caused by the backend. This could be either misconfigured Acquia CMS or misconfigured web server.

Known issues

Laravel Valet

If you are using Laravel Valet as your environment, please see https://github.com/laravel/valet/issues/771#issuecomment-485533478 for a known solution.

Lando

If you are using Lando as your webserver, check your .env.local file and see if https is used as the protocol for NEXT_PUBLIC_DRUPAL_BASE_URL variable. It is a known issue where it seems on Lando setup, the Drupal URL generates with https even if it should use http as the protocol.

PHP built-in web server

Next.js for Acquia CMS is using subrequests which is not compatible with PHP built-in webserver because it is running in a single thread.