Matrix-js-SDK MatrixError: [405] Unrecognized request
maxine-96 opened this issue · comments
Maxine commented
Hey,
I am reaching out to seek assistance with an issue I am encountering while using the Matrix client.
The problem arises when I call the client.joinRoom(roomId) function. It seems that an additional "/?" is appended to the URL, causing the request to fail with a "405 Unrecognized request" error.
The client already exists and the credentials are set correctly. :)
SDK Version 32.0.0
Here are the relevant log entries:
DEBUG FetchHttpApi: <-- POST ?? [92ms 405]
DEBUG FetchHttpApi: <-- POST ?? [90ms 405]
ERROR Error creating room: [M_UNRECOGNIZED: MatrixError: [405] Unrecognized request (https://my-matrix-server/_matrix/client/v3/createRoom/?)]
ERROR Error joining room: [M_UNRECOGNIZED: MatrixError: [405] Unrecognized request (https://my-matrix-server/_matrix/client/v3/join/!ibNGtYzOqOyFMbTGaO%3Amy-matrix-server/?)]
My react native code:
useEffect(() => {
const initMatrixClient = async () => {
try {
const credentials = await getMatrixCredentials();
const matrixClient = createClient({
baseUrl: BASIC_MATRIX_URL,
accessToken: credentials?.accessToken,
deviceId: credentials?.deviceId,
userId: credentials?.userId,
});
setClient(matrixClient);
} catch (error) {
console.log(error)
throw new Error(error);
}
};
initMatrixClient();
}, []);
useEffect(() => {
if (client) {
joinRoom(client)
}
}, [client]);
async function joinRoom(client: MatrixClient): Promise<void> {
console.log(client)
try {
await client.joinRoom(currentRoomId);
} catch (error) {
console.error(`Error: ${error}`);
}
}
Michael Telatynski commented
I don't see anything in the code base that would append /?
. I suggest sharing a minimum reproduction case rather than a subset of one. My guess is whatever fetch polyfill you are using is doing this.