next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

Next.js sites should be environment specific or handled as content. (not as configuration)

Open MokDevelopment opened this issue 3 years ago • 6 comments

I receive error logs as either

  1. localhost is not reachable by the production site when revalidating
  2. the content does not exists on localhost (testing)
  3. editors see the wrong preview

The last one I was able to hack away by creating a custom module that modifies the form. Still kinda ugly.

I understand that seeing "sites" as configuration makes all a bit easier, but it created a lot of issues on the other hand. Are there plans to implement hooks or settings (setting.php) in the future to kind of hide a non env specific "next js destination"?

MokDevelopment avatar Sep 25 '22 20:09 MokDevelopment

One solution is to exclude this config values on every environment. Another one is to use one only environment entry and override it on settings.php.

Exclude on config.

$settings['config_exclude_modules'] = [
  'next.next_site.production',
  'next.next_site.stage',
  'next.next_site.localhost',
];

Override (eg for "localhost")

$next_url = "https://my-drupal-cms-domain.com";
$config['next']['next_site']['localhost']['base_url'] = $next_url;
$config['next']['next_site']['localhost']['preview_url'] = $next_url . "/api/preview";

theodorosploumis avatar Sep 26 '22 07:09 theodorosploumis

@MokDevelopment I was going to suggest what @theodorosploumis said.

Keep your sites configured for your prod environments then in override the values in your settings.local.php.

shadcn avatar Sep 26 '22 07:09 shadcn

@theodorosploumis Thanks sound like a good solution to me.

MokDevelopment avatar Oct 05 '22 13:10 MokDevelopment

Seems that $settings ['config_exclude_modules'] is not for excluding configs. It is for excluding "modules"

https://drupal.stackexchange.com/questions/291639/how-does-the-new-config-exclude-modules-setting-work-exactly

MokDevelopment avatar Feb 05 '23 00:02 MokDevelopment

There is a problem with "status" property. I am not able to overwrite it in settings.local.php And also status should be exposed in form as checkbox and also as column in list. Same like config_split module does.

kmajzlik avatar May 18 '23 21:05 kmajzlik

Override (eg for "localhost")

$next_url = "https://my-drupal-cms-domain.com";
$config['next']['next_site']['localhost']['base_url'] = $next_url;
$config['next']['next_site']['localhost']['preview_url'] = $next_url . "/api/preview";

This doesn't seem to work for me on Drupal 10.1, however the following does:

$next_url = "https://my-drupal-cms-domain.com";
$config['next.next_site.localhost']['base_url'] = $next_url;
$config['next.next_site.localhost']['preview_url'] = $next_url . "/api/preview";

(Replace localhost with your Next.js site id)

dgsiegel avatar Aug 16 '23 13:08 dgsiegel