Redirects being built as http://localhost:8888/drupal8 and not considered safe by RedirectResponseSubscriber

Created on 9 November 2015, about 9 years ago
Updated 8 June 2024, 7 months ago
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Routing 

Last updated 3 days ago

Created by

🇦🇺Australia miniwebs2

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • 🇸🇰Slovakia lubwn

    In my case I was getting error because Drupal is behind reverse proxy. My problem is that it is a bunch of different servers all pointing to different subdirectories, while I do not have an access to the main server where the main website lives.

    So in my case I did not need to "remove" the subdirectory but ADD the subdirectory instead. Which worked, but also resulted in TrustedRedirect errors.

    My settings.php file is:

    $trim_path = '/subdirectory';
    if (isset($GLOBALS['request'])) {
      $request = $GLOBALS['request'];
      if ($request->server->get('SCRIPT_NAME') == "/index.php") {
        $request->server->set('SCRIPT_NAME', '/subdirectory/index.php');
    	$request_uri = $trim_path . substr($request->server->get('REQUEST_URI'), 1);
    	
    	$request->server->set('REQUEST_URI', $request_uri);
      }
    }
    

    To fix trustedRedirect errors I used rather stupid jquery front-end fix, but it works:

    /* Fix trustedRedirectResponse */
    $( document ).ajaxComplete(function (event, xhr, settings) {
    	
    	$("a").each(function() {
    		$(this).attr("href", $(this).attr("href").replace("edit?destination=/node/", "edit?destination=/subdirectory/node/"));
    	});
    	
    });
    

    I had trouble in ajaxified views, which lead to wrong redirects but it was all in GET parameter, so this basicly just replaces href attribute with proper URL.

  • 🇲🇩Moldova gzveri

    #76 is the only solution, clean and worked perfectly for installing Drupal10 in a subfolder of root folder /public_html for a primary domain on linux deluxe shared account on godaddy.

  • 🇫🇷France selinav

    #76 works for me with Drupal10 with hostinger.

    I have adapted the path :

    if (isset($GLOBALS['request']) and
    '/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
    $GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
    }

  • 🇮🇳India zuhair_ak Dubai

    #76 worked for me

Production build 0.71.5 2024