next-drupal
next-drupal copied to clipboard
Next.js sites should be environment specific or handled as content. (not as configuration)
I receive error logs as either
- localhost is not reachable by the production site when revalidating
- the content does not exists on localhost (testing)
- 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"?
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";
@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.
@theodorosploumis Thanks sound like a good solution to me.
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
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.
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)