Problem/Motivation
After upgrading to 8.x-1.0-beta9, we noticed that on certain pages, our custom webfonts were not loading. After much digging and head scratching, we tracked this down to the referrer metatag and its default value of no-referrer. The external font service we're using (Typography.com), expects a referrer value which it uses to check a list of acceptable domains. If this isn't present, it will return: 403 Forbidden.
This issue was only present on new entities or on entities that were just updated. It turns out that the new "referrer" metatag was only being added when a new revision was created. If reverted to a previous revision (prior to updating metatag), the fonts loaded without issue.
To solve for this across the site, the global value for referrer needed to be set to "Origin". Any revisions that had been made since installation needed to be manually set to Origin, since they were now overriding the default.
In my opinion, the key issue here is that the "Referrer" tag is added with or without interaction from a site admin. I believe this is because there is no means by which to leave it blank or otherwise off, since it is a select field and does not have an empty default option. Thus, installing the module enables the referrer metatag with the value of no-referrer.
Referrer metatag was added in issue: #2708511: Referrer metatag support in Drupal 8
Proposed resolution
Since Drupal 8 does not ship with this tag enabled, I think a reasonable solution would be to leave this field disabled unless otherwise instructed by a site admin.
Comments
Comment #2
damienmckennaThere is no default value for the "referrer" meta tag, please check your site's Metatag configurations (admin/config/search/metatag) to see where it's being set.
Comment #3
chrisfree commentedI tested this on a clean Drupal 8 install and realized the following:
Referrer config doesn't exist by default. However, saving any configuration will end up adding the referrer value because you cannot choose any empty value for the referrer field.
I could see how others might end up enabling this tag without realizing it. Or others, like myself, could inadvertently enable it without understanding it's implications.
When I upgraded to the latest beta (on the site that initially made me aware of this change) I did not alter any configuration, but our deployments do import config as a build step. Perhaps that alone will create the referrer config without any user interaction at all?
If I'm understanding correctly, there is no means by which to exclude any metatags that have a select field and do not contain an empty value option as their configuration field. Is that accurate? This would affect "Twitter Cards Type" and "Referrer" as far as I can tell.
Comment #4
damienmckennaOh my! You are absolutely correct! I'm sorry about that.
So yeah, we need the selector to show an "empty" option for this so it won't be saved.
Comment #5
damienmckennaComment #6
chrisfree commentedRight on! I'll try and whip up a patch this afternoon.
Comment #7
chrisfree commentedWhipped up a patch that adds empty values to both the referrer field as well as the Twitter Card Type. Tested without issue.
Comment #8
damienmckennaThanks! Do you think it'd be work going back and purging these values from existing values?
Comment #9
chrisfree commentedDo you mean wiping out any existing config related to these fields? If so, I would say no. We can't know for certain which users wanted the config and which didn't. Perhaps the best approach would be to add something to the readme in the next release?
Comment #10
markdorisonSeemed like there was an extra space after the array key. No functional changes.
Comment #11
damienmckenna@chrisfree: Yeah, will definitely need a changenotice message for this.
@markdorison: Thanks.
Comment #12
chrisfree commented@DamienMcKenna need help drafting something up? Or do you want to take this from here?
Comment #13
bedlamQuestion: is it worth modifying the patch to use the
selectelement's#empty_optionand#empty_valueproperties?Comment #14
damienmckenna@bedlam: Good call, thanks. Yes, it should.
Comment #15
chrisfree commentedUpdated patch. Good catch @bedlam. Now, can we get any more Chromatic developers in this thread?!
@DamienMcKenna let me know if you need anything else!
Comment #16
chrisfree commentedIgnore previous patch. Contained an extraneous line that should've been removed. Here is the one you want.
Comment #17
mmatsoo commentedApplied the patch and the Referrer dropdown now includes the "- None -" option.
Comment #19
damienmckennaCommitted. Thanks!
Comment #20
damienmckennaComment #22
damienmckennaFYI this was causing other problems, e.g. #2781541: Email modal content "breaks" when using metatag module.