Just installed this plugin in D8 (8.8.6) website.
To reproduce the error
1. Login as non admin
2. Enable maintenance mode
3. Refresh page (from non admin user)
4. Page will show errorRedirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.
5. Refresh again, error is gone, maintenance page shows up.
edit:
This doesn't help
$settings['trusted_host_patterns'] = [ '.*' ];
dd($response);
^ Symfony\Component\HttpFoundation\RedirectResponse {#35 ▼
#targetUrl: "/"
+headers: Symfony\Component\HttpFoundation\ResponseHeaderBag {#749 ▼
#computedCacheControl: array:2 [▶]
#cookies: []
#headerNames: array:3 [▶]
#headers: array:3 [▼
"cache-control" => array:1 [▶]
"date" => array:1 [▶]
"location" => array:1 [▼
0 => "/"
]
]
#cacheControl: []
}
#content: """
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url='/'" />
<title>Redirecting to /</title>
</head>
<body>
Redirecting to <a href="/">/</a>.
</body>
</html>
"""
#version: "1.0"
#statusCode: 200
#statusText: "OK"
#charset: null
I read somewhere absolute urls are required?
Comments
Comment #2
lusitaniae commentedComment #3
lusitaniae commentedComment #4
barrett commentedCould you include a full stack trace for the error you're reporting? This module isn't setting a redirect. All it does is set the status code on the response object.
https://git.drupalcode.org/project/maintenance200/-/blob/8.x-1.x/src/Eve...
Comment #5
lusitaniae commentedproposed patch
Comment #6
lusitaniae commentedThanks for looking into this
Hereby the stack trace
Maintenance mode seems to work as expected without using the plugin,
when I enable the plugin it shows the error mentioned in the stack trace.
fyi don't have much experience with Drupal
I understand my patch won't work as intended just now
Comment #7
lusitaniae commentedComment #8
Anonymous (not verified) commentedHave the same error message by updating a out of date module.
User error: Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it. in Drupal\Core\EventSubscriber\RedirectResponseSubscriber->checkRedirectUrl() (line 84 of core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php).
Drupal Version is 8.9.0
Also added the ToolbarController.php patch - for this problem it has'nt fixed it.
Comment #9
lusitaniae commentedComment #10
barrett commentedI have been able to replicate the issue.
When maintenance200 is configured to rewrite the maintenance mode status code, users who have active sessions when maintenance mode is enabled and who do not have the permission to bypass maintenance mode, see the reported error when refreshing a page or navigating between pages.
What I cannot account for at this time is why that's the case, since this module doesn't emit a redirect.
Comment #11
barrett commentedThe patch here is working locally for me. Looks like we just need to not trigger on RedirectRequests. I bet a non-30x code set in there just confuses everyone.
Assuming this does work, we should probably exclude 30x response codes from being set in this module. Not sure what a browser would do if you gave it a 30x response code and no Location header.
Comment #12
seppe beelprez commentedI can confirm that the patch in #11 is working.
Comment #13
barrett commentedThe patch has been merged and released as the 8.x-1.1 release version.