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 apache.conf
, the .htaccess
file, or in the Nginx nginx.conf
file.
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.
-
self
and*
are tokens, and don’t need to be quoted. -
Origins
are 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 (;
).
Conclusion
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.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.