From 3ae61677c2549cd18c16c12c2d9697669c452df2 Mon Sep 17 00:00:00 2001 From: coding4kay Date: Thu, 7 Apr 2022 13:09:12 +0200 Subject: [PATCH] fix bearer header for file upload --- ui/src/pages/Upload.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/src/pages/Upload.tsx b/ui/src/pages/Upload.tsx index 75fa89a8..2eb23449 100644 --- a/ui/src/pages/Upload.tsx +++ b/ui/src/pages/Upload.tsx @@ -1,11 +1,14 @@ import React, { useContext, useState } from 'react' import { Box, Container, makeStyles, Typography } from '@material-ui/core' import CloudUploadIcon from '@material-ui/icons/CloudUpload' +import { AxiosRequestConfig } from 'axios' import HttpService from '../openapi/HttpService' import CustomButton from '../components/Button/CustomButton' import { SnackbarContext } from '../context/Snackbar' import { Translations } from '../utils/Translations' import { CustomTexts } from '../utils/CustomTexts' +import AXIOS_CONFIG from '../openapi/axios-config' +import UserService from '../auth/UserService' const rest = HttpService.getAxiosClient() @@ -46,7 +49,11 @@ const FileUpload = (): JSX.Element => { data.append('name', file.file.name) data.append('file', file.file) rest - .post('/api/sources', data, {}) + .post('/api/sources', data, { + headers: { + Authorization: `Bearer ${UserService.getToken()}`, + }, + }) .then((): void => openSnackbar(Translations.UPLOAD_SUCCESS, 'success') )