Skip to content

Commit

Permalink
fix(gatsby-plugin-netlify): fix merging of path headers (#18203)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerousseau authored and wardpeet committed Oct 8, 2019
1 parent 16e4e0e commit 5cbb741
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ exports[`with security headers 1`] = `
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Content-Security-Policy: frame-ancestors 'self' https://*.storyblok.com/
/hello
X-Frame-Options: SAMEORIGIN
/component---node-modules-gatsby-plugin-offline-app-shell-js-78f9e4dea04737fa062d.js
Cache-Control: public, max-age=31536000, immutable
/0-0180cd94ef2497ac7db8.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ test(`with security headers`, async () => {
`Content-Security-Policy: frame-ancestors 'self' https://*.storyblok.com/`,
`X-Frame-Options: ALLOW-FROM https://app.storyblok.com/`,
],
"/hello": [`X-Frame-Options: SAMEORIGIN`],
},
}

Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-plugin-netlify/src/build-headers-program.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ function headersMerge(userHeaders, defaultHeaders) {
})
merged[path] = Object.values(headersMap)
})
Object.keys(userHeaders).forEach(path => {
if (!merged[path]) {
merged[path] = userHeaders[path]
}
})
return merged
}

Expand Down

0 comments on commit 5cbb741

Please sign in to comment.