You are here

Mega menu 无法保存

 作者:亚艾元技术部

Mega menu配置的时候,添加了一个区块,但是保存不了,用开发者工具查看了一下,出错了。

 

Mixed Content: The page at 'https://www.yaiyuan.com/admin/structure/we-mega-menu/main/config' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.yaiyuan.com/admin/structure/we-mega-menu/save'. This request has been blocked; the content must be served over HTTPS.

 

   根据路径查找源代码,对应的js:

      $.ajax({
        type: "POST",
        url: drupalSettings.WeMegaMenu.saveConfigWeMegaMenuURL,
        data: {
          'action': 'save',
          'menu_name': menu_name,
          'theme': theme,
          'data_config': JSON.stringify(data_config)
        },

 

   对应的PHP:

    $abs_url_save_config = Url::fromRoute('we_megamenu.admin.save', [], ['absolute' => TRUE])->toString();
    $abs_url_reset_config = Url::fromRoute('we_megamenu.admin.reset', [], ['absolute' => TRUE])->toString();
    $abs_url_icons_config = Url::fromRoute('we_megamenu.geticons', [], ['absolute' => TRUE])->toString();
    $build['#attached']['drupalSettings']['WeMegaMenu']['saveConfigWeMegaMenuURL'] = $abs_url_save_config;
    $build['#attached']['drupalSettings']['WeMegaMenu']['resetConfigWeMegaMenuURL'] = $abs_url_reset_config;
$build['#attached']['drupalSettings']['WeMegaMenu']['iconsWeMegaMenuURL'] = $abs_url_icons_config;

 

we_megamenu\src\Controller下面的WeMegaMenuAdminController.php文件中。

 

将['absolute' => TRUE]改为FALSE,应该就可以了。

 

深层次的原因,是我们给网站的nginx服务器多加了一层代码,后端访问Drupal的时候,使用的http。

将代理的https传递过来,应该会比较好。


论坛:

Drupal版本: