You may have rightly implemented the Permissions policy on your web server and got this in your console “Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser.”
That is a sign that your implementation of that header is incorrect. Therefore, in this article, we will help you rectify the above issue and explain the solution.
The above error is related to the new Permissions-Policy HTTP header that is implemented as a replacement to the existing Feature-Policy header which is used to handle the client permissions and other important features.
The Permissions-Policy HTTP header uses a structured syntax giving the website more strict controls and applying restrictions on which origins get to access some features on the end user’s devices.
Fixing the Error with Permissions-Policy Header
This is the format of the header that can be placed in the Apache
.htaccess file, or in the Nginx
Permissions-Policy: fullscreen=(self "https://example.com" "https://another.example.com"), geolocation=*, camera=(), microphone=(), gyroscope=(), payment=("https://*.paypal.com")
This differs from the older Feature-Policy header as shown here.
Feature-Policy: fullscreen 'self' https://example.com https://another.example.com; geolocation ; camera 'none'; microphone 'none'; gyroscope 'none'; payment https://.paypal.com
These are the differences to look out for that might be the cause of errors in the Permissions-Policy header when trying to use the Feature-Policy syntax.
*are tokens, and don’t need to be quoted.
Originsare strings representing domain names and should be enclosed within double quotes.
- Allow lists are normally enclosed in parentheses and can be omitted if there is only a single element.
- Decalarations are separated by a comma (
,) and not semi-colons (
Hopefully going forward you won’t encounter the “Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser.” message after you set your Permissions-Policy header correctly.