Skip to content

OPTIONS preflight request missing critical headers causing upload failure in Docker/localhost environments #96

@mohsentaleb

Description

@mohsentaleb

When using FileUploaderRegular in a Docker development environment, the OPTIONS preflight request to Uploadcare's API hangs indefinitely, causing file uploads to fail with a 405 error.

The core issue: The React uploader's OPTIONS preflight request is missing critical browser headers compared to the working jQuery widget, causing the request to hang.

Comparison of OPTIONS Requests:

✅ Working (jQuery widget) - includes these headers:

Accept-Language: en-US,en;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Pragma: no-cache
Referer: http://127.0.0.1:8000/
Sec-Fetch-Dest: empty
Sec-Fetch-Site: cross-site

❌ Failing (React uploader) - missing all of the above headers

The incomplete OPTIONS request causes the preflight to hang indefinitely (stays in "pending" state in Network tab), and the subsequent POST request fails.

Steps to reproduce:

  1. Set up a React app in Docker, accessed via http://localhost:8000 or http://127.0.0.1:8000
  2. Import and use FileUploaderRegular component
  3. Drop or select an image file
  4. Open browser DevTools → Network tab
  5. Observe: OPTIONS request to https://upload.uploadcare.com/base/?jsonerrors=1 stays in "pending"
  6. Eventually get error: {"error": {"status_code": 405, "content": "HTTP method GET is not allowed for /base/", "error_code": "MethodNotAllowedError"}}

Note: The old jQuery Uploadcare widget works perfectly in the same environment with identical setup.

Expected behavior

The OPTIONS preflight request should complete successfully with status 200 (like the jQuery widget does), followed by a successful POST request uploading the file.

Code / screenshots

import { FileUploaderRegular } from '@uploadcare/react-uploader';
import '@uploadcare/react-uploader/core.css';

function App() {
  return (
    <FileUploaderRegular
      pubkey="demopublickey"
      onChange={(e) => console.log('File uploaded:', e.detail)}
    />
  );
}

Network tab showing hanging OPTIONS request:

  • OPTIONS request: Status "pending" (never completes)
  • POST request: Status 405 "Method Not Allowed"

Working jQuery widget OPTIONS request completes in ~20ms with status 200

Environment

  • Library version: @uploadcare/react-uploader@1.10.2 (also tested with 1.8.1, same issue)
  • Language/framework version: React 18, TypeScript 5
  • OS version: WSL, running in Docker container, accessed via Chrome 141.0.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions