htmliframex-frame-options

How to fix Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin


I'm getting an error while using an i-frame in angular. It refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'

Refused to display 'https://docs.google.com/gview?url=https://subtreebucket.s3.amazonaws.com/docsFile_1559124133664_dummy.pdf' in a frame because it set 'X-Frame-Options' to 'sameorigin'.


Solution

  • Please use santizer with safe pipe and then include the link as below

    <iframe class="doc" src="https://docs.google.com/gview?url=https://subtreebucket.s3.amazonaws.com/docsFile_1559124133664_dummy.pdf&embedded=true"></iframe>
    

    Make sure you are using embedded=true while adding source in the iframe. It'll definitely work