Skip to content

Commit ebbb41b

Browse files
GatsbyJS Botsidharthachatterjee
GatsbyJS Bot
andauthoredMar 18, 2021
fix(gatsby-plugin-netlify): Add an allow list for redirect options (#30155) (#30215)
(cherry picked from commit 962c4a1) Co-authored-by: Sidhartha Chatterjee <me@sidharthachatterjee.com>

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎packages/gatsby-plugin-netlify/src/create-redirects.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ export default async function writeRedirectsFile(
1212

1313
const FILE_PATH = publicFolder(`_redirects`)
1414

15-
// Map redirect data to the format Netlify expects
1615
// https://www.netlify.com/docs/redirects/
16+
const NETLIFY_REDIRECT_KEYWORDS_ALLOWLIST = [
17+
`query`,
18+
`conditions`,
19+
`headers`,
20+
`signed`,
21+
`edge_handler`,
22+
`Language`,
23+
`Country`,
24+
]
25+
26+
// Map redirect data to the format Netlify expects
1727
redirects = redirects.map(redirect => {
1828
const {
1929
fromPath,
@@ -43,7 +53,9 @@ export default async function writeRedirectsFile(
4353
`Values should not contain spaces.`
4454
)
4555
} else {
46-
pieces.push(`${key}=${value}`)
56+
if (NETLIFY_REDIRECT_KEYWORDS_ALLOWLIST.includes(key)) {
57+
pieces.push(`${key}=${value}`)
58+
}
4759
}
4860
}
4961

0 commit comments

Comments
 (0)
Please sign in to comment.