Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers Are Being Passed with a map Object #4806

Open
Touseef-ahmad opened this issue Jan 7, 2025 · 1 comment
Open

Headers Are Being Passed with a map Object #4806

Touseef-ahmad opened this issue Jan 7, 2025 · 1 comment

Comments

@Touseef-ahmad
Copy link

Description:
I have encountered an issue where the Authorization header is being passed within a map object instead of directly in the headers. This is preventing the proper transmission of the headers in requests. The headers object looks like:

{
  "headers": {
    "map": {
      "authorization": "Bearer <token>"
    }
  }
}

This structure is causing issues because the expected format should be:

{
  "headers": {
      "authorization": "Bearer <token>"
  }
}
const baseQuery = fetchBaseQuery({
  baseUrl: API_BASE_URL,
  prepareHeaders: (headers, {getState}) => {
    const access_token = (getState() as RootState).auth.access;
    if (access_token) {
      headers.set('Authorization', `Bearer ${access_token}`);
    }
    return headers;
  },
  headers: {
    'Content-Type': 'application/json',
  },
});
Image

Using this with "react-native": "0.76.5", "@reduxjs/toolkit": "^2.5.0",

@markerikson
Copy link
Collaborator

RTKQ does not have any code that would do that. Can you provide a repro of this happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants