Skip to content

Commit 0867b58

Browse files
committedApr 7, 2025··
Use vercel protection bypass headcer
Builds were previously breaking when UDR attempted to make HTTP requests to the CDN (vercel public folder) to retrieve content. Adding the `x-vercel-protection-bypass` header should fix that
1 parent 7344d24 commit 0867b58

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎.github/workflows/build-pr-preview.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ jobs:
219219
cd unified-docs-frontend-preview
220220
echo "HASHI_ENV=unified-docs-sandbox" >> .env
221221
echo "UNIFIED_DOCS_API=${{ needs.deploy-unified-docs-api-preview.outputs.preview_url }}" >> .env
222-
222+
echo "VERCEL_AUTOMATION_BYPASS_SECRET=${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}" >> .env
223+
223224
- name: Build dev-portal
224225
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
225226
env:
@@ -304,7 +305,7 @@ jobs:
304305
--max-concurrency 24
305306
--no-progress
306307
--verbose
307-
--header x-vercel-protection-bypass ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
308+
--header x-vercel-protection-bypass=${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
308309
fail: false
309310
env:
310311
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

‎app/utils/file.ts

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const SELF_URL = process.env.VERCEL_URL
1212
? `https://${process.env.VERCEL_URL}`
1313
: `http://localhost:${process.env.UNIFIED_DOCS_PORT}`
1414

15+
const headers = process.env.VERCEL_URL
16+
? new Headers({
17+
'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET,
18+
})
19+
: new Headers()
20+
1521
/**
1622
* NOTE: we currently read files by fetching them from the `public` folder
1723
* via the Vercel CDN.
@@ -21,6 +27,7 @@ export const readFile = async (filePath: string[]) => {
2127
try {
2228
const res = await fetch(`${SELF_URL}/${filePath.join('/')}`, {
2329
cache: 'no-cache',
30+
headers,
2431
})
2532

2633
if (!res.ok) {
@@ -49,6 +56,7 @@ export const getAssetData = async (
4956
try {
5057
const res = await fetch(`${SELF_URL}/${filePath.join('/')}`, {
5158
cache: 'no-cache',
59+
headers,
5260
})
5361

5462
if (!res.ok) {

0 commit comments

Comments
 (0)
Please sign in to comment.