Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ur): return 404 if process id cannot be extracted from request #790 #791

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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