Skip to content

Commit

Permalink
feat(Deployment-Server): Proxy support for Artifact URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozzim committed May 13, 2022
1 parent 1925259 commit 0717616
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/deployment-server/src/deployment-artifacts/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,21 @@ export default function deploymentArtifactsRoutes (router: Router): void {
return res.sendStatus(400)
}

const host = req.get('host')
let host = req.get('host')

if (host == null) {
return res.sendStatus(500)
}

const { protocol, originalUrl: url } = req
const url= req.originalUrl
let protocol = req.protocol

// Adjust host and protocol in case of proxies
if (req.headers['x-forwarded-host'])
host = req.headers['x-forwarded-host'] as string

if (req.headers['x-forwarded-proto'])
protocol = req.headers['x-forwarded-proto'] as string

const artifactUri = req.file.linkUrl ?? `${protocol}://${host}${url}/${req.file.filename}`
return res.json({ artifactUri })
Expand Down

0 comments on commit 0717616

Please sign in to comment.