Issue with Uppercase HTTP Headers and Axios in React Native

Tiempo de lectura: < 1 minuto

Reading time: < 1 minute

When using axios and attaching a header, like in the following example:

 const config = {
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "TOKEN-AUTH": token
        }
    };

We need to be careful with headers that have uppercase letters because axios automatically converts them to lowercase.

If our backend server expects to receive the header TOKEN-AUTH in uppercase, we also need to allow receiving the header token-auth since axios automatically converts headers to lowercase when the app is running on Android/iOS.

The best practice is to avoid using headers with uppercase names to prevent these kinds of errors.

Leave a Comment