Skip to content

Commit

Permalink
🔒️ improve security headers, support for articles too
Browse files Browse the repository at this point in the history
  • Loading branch information
ciphrd committed Sep 2, 2022
1 parent 4f5db82 commit aaf3e7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
13 changes: 3 additions & 10 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const baseSecurityHeaders = [
},
]

const articlesAllowedDomains = "https://*.spotify.com/ https://spotify.com https://*.youtube.com/ https://youtube.com https://*.twitter.com/ https://twitter.com"


/** @type {import('next').NextConfig} */
module.exports = withBundleAnalyzer({
Expand All @@ -40,7 +42,7 @@ module.exports = withBundleAnalyzer({
headers: [
{
key: "Content-Security-Policy",
value: `frame-ancestors 'self'; frame-src ${process.env.NEXT_PUBLIC_IPFS_GATEWAY_SAFE};`
value: `frame-ancestors 'self'; frame-src ${process.env.NEXT_PUBLIC_IPFS_GATEWAY_SAFE} ${articlesAllowedDomains} 'self';`
},
...baseSecurityHeaders,
]
Expand All @@ -54,15 +56,6 @@ module.exports = withBundleAnalyzer({
}
]
},
{
source: "/sandbox",
headers: [
{
key: "Content-Security-Policy",
value: `frame-ancestors 'self';`
},
]
},
{
source: "/sandbox/preview.html",
headers: [
Expand Down
1 change: 1 addition & 0 deletions src/components/NFTArticle/elements/Embed/EmbedSpotify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const EmbedSpotify = memo<EmbedElementProps>(({ href }) => {
className={style.spotify}
src={src} width="660px"
height="380" frameBorder="0"
sandbox="allow-same-origin allow-scripts"
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture">
</iframe>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/NFTArticle/elements/Embed/EmbedYoutube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const EmbedYoutube = memo<EmbedElementProps>(({ href }) => {
src={embedUrl}
title="YouTube video player"
frameBorder="0"
sandbox="allow-same-origin allow-scripts"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"
>
</iframe>
Expand Down

1 comment on commit aaf3e7a

@vercel
Copy link

@vercel vercel bot commented on aaf3e7a Sep 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.