Skip to content

Commit af2d935

Browse files
authored
Update to use x-host header (#53780)
1 parent c2101c4 commit af2d935

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/archives/middleware/archived-enterprise-versions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,18 @@ export default async function archivedEnterpriseVersions(
227227
// old Azure Blob Storage URL. These need to be rewritten to
228228
// the new archived enterprise repo URL.
229229
if (versionSatisfiesRange(requestedVersion, `>=${firstReleaseStoredInBlobStorage}`)) {
230+
// `x-host` is a custom header set by Fastly.
231+
// GLB automatically deletes the `x-forwarded-host` header.
232+
const host = req.get('x-host') || req.get('x-forwarded-host') || req.get('host')
230233
r.body = r.body
231234
.replaceAll(
232235
`${OLD_AZURE_BLOB_ENTERPRISE_DIR}/${requestedVersion}/assets/cb-`,
233236
`${ENTERPRISE_GH_PAGES_URL_PREFIX}${requestedVersion}/assets/cb-`,
234237
)
235238
.replaceAll(
236239
`${OLD_AZURE_BLOB_ENTERPRISE_DIR}/${requestedVersion}/`,
237-
`${req.protocol}://docs.github.com/enterprise-server@${requestedVersion}/`,
240+
`${req.protocol}://${host}/enterprise-server@${requestedVersion}/`,
238241
)
239-
// TODO host: req.get('x-forwarded-host') || req.get('host')
240242
}
241243

242244
// Releases 3.1 and lower were previously hosted in the

0 commit comments

Comments
 (0)