Unable to send additional headers to companion with AwsS3Multipart

I have an express app using @uppy/companion as a middleware and I want to add JWT for authentication.

But I can’t send the Authorization header from the client and can’t figure out why. Please help me out.

I’ve tried both configuration properties serverHeaders and companionHeaders but none of them works. Here my uppy configuration on client side.

const uppy = new Core({
  autoProceed: true,
  debug: true,
})
  .use(AwsS3Multipart, {
    companionUrl: 'http://localhost:3001/',
    serverHeaders: {
      Authorization: 'Basic jfawoiejfoawejifj',
    },
    companionHeaders: {
      Authorization: 'Basic jfawoiejfoawejifj',
    },
  })
1 Like

I’ve figured it out. I missed some configuration for CORS from the companion server.

It must allow options method, allow additional headers in Access-Control-Allow-Headers and expose it for options method

here my solution

app.use(cors({
  methods: ['OPTIONS', 'GET', 'POST', 'PATCH', 'PUT'],
  allowedHeaders: ['Content-Type', 'Authorization', 'Uppy-Versions', 'Accept'],
  exposedHeaders: ['Access-Control-Allow-Headers'],
}));
1 Like