When a domain record is not setup up (yet) domain_source redirect throws error

Created on 5 April 2021, over 3 years ago
Updated 14 June 2023, over 1 year ago

Drupal Version

9.1.5

Domain module version

1.0.0-beta5

Expected Behavior

Sometimes we need to setup domain records where we don't have control over the actual domain yet (e.g. the old site still runs on it and it's only on day X to switch domains and before you want your editors create all the content, or the domain still needs to be registered).

I marked this as a support request to learn if there is a recommended workaround for this. I think the scenario described above is not too unusual. I currently don't see an option to e.g. to mark a domain alias as main domain so that the redirect would point to a valid temporary domain until we launch the site on the final domain. If there was, then the site builder would be responsible to set this up properly, I'd say.

Actual Behavior

Let's say domain2 still points to another server, but we already set it up as domain record:

If an editor selects domain2 as domain source of a node and saves it, we are seeing a WSOD which says:

Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it. 

On another occasions (where the domain record is not properly configured, I haven't figured out what is wrong exactly or if it is just not yet known to DNS) I got a backtrace and the error was not a WSOD but displayed on the page - however I can't reproduce this scenario:

User error: Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it. in Drupal\domain_source\EventSubscriber\DomainSourceRedirectResponseSubscriber->checkRedirectUrl() (line 60 of modules/contrib/domain/domain_source/src/EventSubscriber/DomainSourceRedirectResponseSubscriber.php).
Drupal\domain_source\EventSubscriber\DomainSourceRedirectResponseSubscriber->checkRedirectUrl(Object, 'kernel.response', Object)
call_user_func(Array, Object, 'kernel.response', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.response') (Line: 191)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 245)
Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object, Object, 1) (Line: 91)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

- Enable domain_source
- Configure domain record 1: domain1.org properly
- Configure domain record 2: Let domain2.org point to some other server (or enter a random domain)
- From domain1.org, on node add or edit form select domain2.org as domain source
- Save node, system tries do redirected to domain2.org/node/1 which fails with WSOD

πŸ’¬ Support request
Status

Active

Component

- Domain Source

Created by

πŸ‡©πŸ‡ͺGermany anruether Bonn

Live updates comments and jobs are added and updated live.
  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bsnodgrass

    Reviewing for πŸ“Œ Documentation for 2.0.x Active ...

    Has this issue been resolved? Can you duplicate after updating to the 2.0.0-beta1 release?

    Per the project description, "The 2.0.0-beta1 release is a code-only update from 8.x-1.0-beta8. Upgrading should only require a cache clear. The 8.x-1.x branch is now deprecated and will receive no new commits or releases."

    Relating the issue, keeping the status. Does anyone have more information or suggestions?

Production build 0.71.5 2024