Skip to content

Commit 5bd889e

Browse files
authored
feat(gatsby-plugin-benchmark-reporting): allow passing a secret to benchmark reporting endpoint (#22108)
* pass x-benchmark-secret in headers with call to benchmarks api * exit on 401 if we receive one
1 parent b28c27a commit 5bd889e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/gatsby-plugin-benchmark-reporting/src/gatsby-node.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,17 @@ class BenchMeta {
249249
method: `POST`,
250250
headers: {
251251
"content-type": `application/json`,
252-
// "user-agent": this.getUserAgent(),
252+
"x-benchmark-secret": process.env.BENCHMARK_REPORTING_SECRET,
253253
},
254254
body: json,
255255
}).then(res => {
256256
lastStatus = res.status
257-
if (lastStatus === 500) {
258-
reportInfo(`Got 500 response, waiting for text`)
257+
if ([401, 500].includes(lastStatus)) {
258+
reportInfo(`Got ${lastStatus} response, waiting for text`)
259259
res.text().then(content => {
260260
reportError(
261261
`Response error`,
262-
new Error(`Server responded with a 500 error: ${content}`)
262+
new Error(`Server responded with a ${lastStatus} error: ${content}`)
263263
)
264264
process.exit(1)
265265
})

0 commit comments

Comments
 (0)