Skip to content

401 Unauthorized on PDF Upload #467

@sahilds1

Description

@sahilds1

Steps to Reproduce

  1. Log in to the application
  2. Navigate to the Document Manager page
  3. Click "Upload File" and select a PDF
  4. Observe POST /api/v1/api/uploadFile returns 401 Unauthorized

Possible Fix Background

The project has two axios instances in frontend/src/api/apiClient.ts:

  • publicApi — no auth headers
  • adminApi — attaches Authorization: JWT from localStorage via a request interceptor

UploadFile.tsx:25 uses a raw axios.post(...) call (neither publicApi nor adminApi), so no Authorization header is sent. The backend UploadFileView
(server/api/views/uploadFile/views.py:21) requires IsAuthenticated for all non-GET methods, causing the 401.


Possible Fix

In frontend/src/pages/DocumentManager/UploadFile.tsx:

  1. Replace import axios from "axios" with import { adminApi } from "../../api/apiClient.ts"
  2. Change the upload call from axios.post(...) to adminApi.post(...) — the interceptor will automatically attach the JWT token, no other changes needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions