Skip to content

Commit 23d52a0

Browse files
fix: return early if pasteURL is not defined (#15748)
Returns a proper error message when pasteURL is not defined.
1 parent 30fee83 commit 23d52a0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/payload/src/uploads/endpoints/getFileFromURL.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export const getFileFromURLHandler: PayloadHandler = async (req) => {
2121

2222
const config = collection?.config
2323

24+
if (!config.upload?.pasteURL) {
25+
throw new APIError('Pasting from URL is not enabled for this collection.', 400)
26+
}
27+
2428
if (id) {
2529
// updating doc
2630
const accessResult = await executeAccess({ req }, config.access.update)
@@ -48,10 +52,7 @@ export const getFileFromURLHandler: PayloadHandler = async (req) => {
4852

4953
const validatedUrl = new URL(src)
5054

51-
if (
52-
typeof config.upload?.pasteURL === 'object' &&
53-
!isURLAllowed(validatedUrl.href, config.upload.pasteURL.allowList)
54-
) {
55+
if (!isURLAllowed(validatedUrl.href, config.upload.pasteURL.allowList)) {
5556
throw new APIError(`The provided URL (${validatedUrl.href}) is not allowed.`, 400)
5657
}
5758

0 commit comments

Comments
 (0)