Skip to content

Commit a374aab

Browse files
authored
fix(ui): bulk upload issues (#13413)
### What? This PR contains a couple of fixes to the bulk upload process: - Credentials not being passed when fetching, leading to auth issues - Provide a fallback to crypto.randomUUID which is only available when using HTTPS or localhost ### Why? I use [separate admin and API URLs](#12682) and work off a remote dev server using custom hostnames. These issues may not impact the happy path of using localhost, but are dealbreakers in this environment. ### Fixes # _These are issues I found myself, I fixed them rather than raising issues for somebody else to pick up, but I can create issues to link to if required._
1 parent 2bc9a2d commit a374aab

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/ui/src/elements/BulkUpload/FormsManager/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function FormsManagerProvider({ children }: FormsManagerProps) {
127127
const initialStateRef = React.useRef<FormState>(null)
128128
const getFormDataRef = React.useRef<() => Data>(() => ({}))
129129

130-
const actionURL = `${api}/${collectionSlug}`
130+
const actionURL = `${serverURL}${api}/${collectionSlug}`
131131

132132
const initializeSharedDocPermissions = React.useCallback(async () => {
133133
const params = {
@@ -301,6 +301,7 @@ export function FormsManagerProvider({ children }: FormsManagerProps) {
301301
collectionSlug,
302302
getUploadHandler({ collectionSlug }),
303303
),
304+
credentials: 'include',
304305
method: 'POST',
305306
})
306307

packages/ui/src/elements/BulkUpload/FormsManager/reducer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { FormState, UploadEdits } from 'payload'
22

3+
import { v4 as uuidv4 } from 'uuid'
4+
35
export type State = {
46
activeIndex: number
57
forms: {
@@ -50,7 +52,7 @@ export function formsManagementReducer(state: State, action: Action): State {
5052
for (let i = 0; i < action.files.length; i++) {
5153
newForms[i] = {
5254
errorCount: 0,
53-
formID: crypto.randomUUID(),
55+
formID: crypto.randomUUID ? crypto.randomUUID() : uuidv4(),
5456
formState: {
5557
...(action.initialState || {}),
5658
file: {

packages/ui/src/elements/Table/OrderableTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ export const OrderableTable: React.FC<Props> = ({
119119
target,
120120
}
121121

122-
const response = await fetch(`${config.routes.api}/reorder`, {
122+
const response = await fetch(`${config.serverURL}${config.routes.api}/reorder`, {
123123
body: JSON.stringify(jsonBody),
124+
credentials: 'include',
124125
headers: {
125126
'Content-Type': 'application/json',
126127
},

0 commit comments

Comments
 (0)