Tech Blog :: Drupal Fix: Ajax and Secure Pages


Jun 30 '10 9:07pm
Tags

Drupal Fix: Ajax and Secure Pages

Drupal's Secure Pages module is great for enforcing HTTPs/SSL on particular parts of a site. But it's known to have a problem with Ajax, especially (for my purposes) autocomplete fields in node forms. The solution is to toggle https:// in $base_url so it's not seen as cross-domain, and that's most easily done by putting this line in settings.php (changing mysite.com as needed):

$base_url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 'https://' : 'http://') . 'mysite.com';

Thanks! This was the problem I was having; this quick solution fixed it.

You can also just comment out $base_url in Drupal 5 and 6, since it's not necessary and introduces a lot of odd behaviors, like this one.

Post new comment

Don't bother putting in spam links. They'll be set to rel=nofollow and will be removed and reported as spam shortly after submitting.

The content of this field is kept private and will not be shown publicly.
CAPTCHA
Are you human?