Authorization header missing on /threads/{thread_id}/history request when using useStream with defaultHeaders #615

Closed
opened 2026-02-20 17:40:58 -05:00 by yindo · 2 comments
Owner

Originally created by @zyoung1212 on GitHub (May 8, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

const thread = useStream({
  apiUrl: 'http://localhost:2024',
  assistantId: "app",
  threadId: threadId,
  onThreadId: setThreadId,
  messagesKey: "messages",
  defaultHeaders: {
    Authorization: `Bearer ${token}`,
  }
});

Error Message and Stack Trace (if applicable)


Description

Hi LangGraph team,

I'm currently developing a LangGraph application using the officially recommended React frontend from the guide here:
https://langchain-ai.github.io/langgraph/cloud/how-tos/use_stream_react

I have implemented authentication and am passing a token through the Authorization header.

The token is successfully included when sending messages (e.g., to /stream、/threads). However, I noticed that when a request is sent to /threads/{thread_id}/history, the token is not included in the headers, resulting in a 403 error from my backend.

System Info

"@langchain/core": "^0.3.49",
"@langchain/langgraph-sdk": "^0.0.74",

langgraph_api: 0.1.17
langchain_core: 0.3.56
langchain: 0.3.24
langgraph_sdk: 0.1.63

Originally created by @zyoung1212 on GitHub (May 8, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python const thread = useStream({ apiUrl: 'http://localhost:2024', assistantId: "app", threadId: threadId, onThreadId: setThreadId, messagesKey: "messages", defaultHeaders: { Authorization: `Bearer ${token}`, } }); ``` ### Error Message and Stack Trace (if applicable) ```shell ``` ### Description Hi LangGraph team, I'm currently developing a LangGraph application using the officially recommended React frontend from the guide here: https://langchain-ai.github.io/langgraph/cloud/how-tos/use_stream_react I have implemented authentication and am passing a token through the Authorization header. The token is successfully included when sending messages (e.g., to /stream、/threads). However, I noticed that when a request is sent to /threads/{thread_id}/history, the token is not included in the headers, resulting in a 403 error from my backend. ### System Info "@langchain/core": "^0.3.49", "@langchain/langgraph-sdk": "^0.0.74", > langgraph_api: 0.1.17 > langchain_core: 0.3.56 > langchain: 0.3.24 > langgraph_sdk: 0.1.63
yindo closed this issue 2026-02-20 17:40:58 -05:00
Author
Owner

@zyoung1212 commented on GitHub (May 8, 2025):

Image Image
@zyoung1212 commented on GitHub (May 8, 2025): <img width="1105" alt="Image" src="https://github.com/user-attachments/assets/dbbc77bd-84c6-42d5-845d-25efcf07ceb7" /> <img width="1010" alt="Image" src="https://github.com/user-attachments/assets/aa8a140a-ebfa-4f38-92d2-ff26a47a5426" />
Author
Owner

@zyoung1212 commented on GitHub (May 8, 2025):

sorry, it's my bug.
Fixed code example:

export default function Home() {
  const initialToken =
    typeof window !== "undefined" ? localStorage.getItem("token") : null;
  const [token, setToken] = useState(initialToken);

  if (!token) return <p>Loading...</p>;

  const thread = useStream({
        apiUrl: 'http://localhost:2024',
        assistantId: "app",
        threadId: threadId,
        onThreadId: setThreadId,
        messagesKey: "messages",
        defaultHeaders: {
            Authorization: `Bearer ${token}`,
        }
    });

  /* ...other code... */
}
@zyoung1212 commented on GitHub (May 8, 2025): sorry, it's my bug. Fixed code example: ```js export default function Home() { const initialToken = typeof window !== "undefined" ? localStorage.getItem("token") : null; const [token, setToken] = useState(initialToken); if (!token) return <p>Loading...</p>; const thread = useStream({ apiUrl: 'http://localhost:2024', assistantId: "app", threadId: threadId, onThreadId: setThreadId, messagesKey: "messages", defaultHeaders: { Authorization: `Bearer ${token}`, } }); /* ...other code... */ } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#615