Skip to content
Open
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
5 changes: 3 additions & 2 deletions src/http/routes/tus/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export function generateUrl(

const forwardedPath = req.headers['x-forwarded-prefix']
if (requestAllowXForwardedPrefix && typeof forwardedPath === 'string') {
basePath = forwardedPath + path
// Remove trailing slash from forwardedPath to avoid double slashes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar pattern could happen for signV4 of canonical request if this feature requestAllowXForwardedPrefix is enabled or a configuration value ending with a slash is given. I believe, as a result, it can cause SignatureDoesNotMatch errors

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

basePath = forwardedPath.replace(/\/+$/, '') + path
}

const isSigned = req.url?.endsWith(SIGNED_URL_SUFFIX)
Expand Down Expand Up @@ -264,7 +265,7 @@ export async function onUploadFinish(rawReq: Request, upload: Upload) {
if (upload.metadata?.metadata) {
try {
customMd = JSON.parse(upload.metadata.metadata)
} catch (e) {
} catch {
// no-op
}
}
Expand Down
Loading