From 0902bb552944c39f83dd5172402b280196347075 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 1 Apr 2021 08:43:28 +0800 Subject: [PATCH] fix: missing upload headers --- packages/app/src/components/form.fields/upload/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/app/src/components/form.fields/upload/index.tsx b/packages/app/src/components/form.fields/upload/index.tsx index 8ab1a19a7..8475366be 100644 --- a/packages/app/src/components/form.fields/upload/index.tsx +++ b/packages/app/src/components/form.fields/upload/index.tsx @@ -194,6 +194,7 @@ export const Upload = connect({ const [fileList, setFileList] = useState(toFileList(value)); const uploadProps = { name: 'file', + headers: {}, action: `${process.env.API}/attachments:upload`, onChange({ fileList }) { console.log(fileList); @@ -202,6 +203,10 @@ export const Upload = connect({ onChange(multiple ? list : list.shift() || null); }, }; + const token = localStorage.getItem('NOCOBASE_TOKEN'); + if (token) { + uploadProps.headers['Authorization'] = `Bearer ${token}`; + } const images = getImgUrls(fileList); console.log({ fileList }); return (