Skip to content

fix message file upload #401

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

Merged
merged 1 commit into from
Apr 15, 2025
Merged

fix message file upload #401

merged 1 commit into from
Apr 15, 2025

Conversation

kaioken
Copy link
Member

@kaioken kaioken commented Apr 15, 2025

The problem is in the createMessageWithFile method, which isn't properly including the user authentication when sending the file upload request.
Looking at your code, I can see that:

The axiosClient is being created with the app key and admin key in the headers
There's an interceptor using this.options.authAxiosMiddleware, but this isn't being properly applied when making the FormData POST request
Unlike other methods that use the GraphQL client (which has all middleware properly configured), the direct axios POST doesn't include the user authorization token

The solution is to explicitly get the authorization headers from the middleware and include them in the request. Here's what's happening and how to fix it:

The authAxiosMiddleware function in KanvasCore returns an object with the Authorization header
However, when making the FormData request, you're not including these headers in the POST request
You need to explicitly call the middleware to get the auth headers and add them to your request

@kaioken kaioken merged commit 1024e84 into main Apr 15, 2025
1 of 3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants