Skip to content

Commit

Permalink
fix(ur): return 404 if process id cannot be extracted from request #790
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jun 12, 2024
1 parent 7d3833b commit 04b49bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions servers/ur/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function proxyWith ({ aoUnit, hosts, subrouterUrl, surUrl, owners, proces
always(async (req, res) => {
const processId = await processIdFromRequest(req)

if (!processId) return res.status(404).send({ error: 'Process id not found on request' })

async function revProxy ({ failoverAttempt, err }) {
/**
* In cases where we have to consume the request stream before proxying
Expand Down
5 changes: 5 additions & 0 deletions servers/ur/src/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ export function redirectWith ({ aoUnit, hosts, subrouterUrl, surUrl, owners, pro
* by the injected business logic.
*/
const redirectHandler = ({ processIdFromRequest }) => {
// TODO: should we compose an error handler, similar to proxy.js?
// for now, just keeping as is.
return async (req, res) => {
const processId = await processIdFromRequest(req)

if (!processId) return res.status(404).send({ error: 'Process id not found on request' })

const host = await determineHost({ processId })

_logger('Redirecting process %s to host %s', processId, host)
Expand Down

0 comments on commit 04b49bf

Please sign in to comment.