Uppy Tus doesn't work on node js

I get an error when trying to send a file to the server. The browser version works, the files are uploaded to the server, but in the node js environment I get an error

import { Uppy } from "@uppy/core";
import Tus from "@uppy/tus";

async def main() {
  const uppy = new Uppy({ debug: true }).use(Tus, {
    endpoint: "http://192.168.100.104/api/files",
    headers: {
      Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "X-Topic-Id": "6764658aed40b628cfd4c1df",
    }
  });
    
  const file = fs.createReadStream("./test.mp4");
  uppy.addFile({
    name: "test.mp4",
    data: file
    });
    
  await uppy.upload();
}

main();

Short error:

tus: failed to create upload, caused by TypeError: Cannot set properties of null (setting ‘withCredentials’), originated from request (method: POST, url: http://192.168.100.104/api/files, response code: n/a, response text: n/a, request id: n/a)

Full Error:

Using Core v4.3.1
[Uppy] [02:26:44] Using Tus v4.1.5
[Uppy] [02:26:44] Added file: backup.sql, uppy-backup/sql-1e-application/x-sql-structure/////////////////////backup/sql-2s-11h-11u-11r-11l-11l-10-11v-11u-11k-120-11u-11h-11t-11u-2s-121-11i-11l-122-2s-1e, mime type: application/x-sql
[Uppy] [02:26:44] [Tus] Uploading…
[Uppy] [02:26:54] DetailedError2: tus: failed to create upload, caused by TypeError: Cannot set properties of null (setting ‘withCredentials’), originated from request (method: POST, url: http://192.168.100.104/api/files, response code: n/a, response text: n/a, request id: n/a)
at Upload3._emitHttpError (D:\Code\NodeJs\uppy-test\app.js:19037:27)
at D:\Code\NodeJs\uppy-test\app.js:19177:20 {
originalRequest: Request3 {
_method: ‘POST’,
_url: ‘http://192.168.100.104/api/files’,
_headers: {
‘Tus-Resumable’: ‘1.0.0’,
Authorization: ‘Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3NDE1OWRmYWJiY2JjOGQ4ZmU1NmMxZSIsImlhdCI6MTczNDY0MzYwMSwiZXhwIjoxNzM0NzMwMDAxfQ.mejIKScs639Msp4iXRs282YofvAO0J0w_YmRIC3NiLY’,
‘X-Topic-Id’: ‘6764658aed40b628cfd4c1df’,
‘Upload-Length’: ‘110550’,
‘Upload-Metadata’: ‘relativePath c3RydWN0dXJlXNCR0L7Qu9C10LUg0L/QvtC00YDQvtCx0L3QvlzQodCy0LXRglxiYWNrdXAuc3Fs,name YmFja3VwLnNxbA==,type YXBwbGljYXRpb24veC1zcWw=,filetype YXBwbGljYXRpb24veC1zcWw=,filename YmFja3VwLnNxbA==’
},
_request: null,
_progressHandler: [Function (anonymous)],
_requestOptions: {}
},
originalResponse: null,
causingError: TypeError: Cannot set properties of null (setting ‘withCredentials’)
at uploadOptions.onBeforeRequest (D:\Code\NodeJs\uppy-test\app.js:34750:27)
at _callee$ (D:\Code\NodeJs\uppy-test\app.js:19473:30)
at tryCatch (D:\Code\NodeJs\uppy-test\app.js:18270:21)
at Generator. (D:\Code\NodeJs\uppy-test\app.js:18356:22)
at Generator.next (D:\Code\NodeJs\uppy-test\app.js:18297:25)
at asyncGeneratorStep (D:\Code\NodeJs\uppy-test\app.js:18524:28)
at _next3 (D:\Code\NodeJs\uppy-test\app.js:18542:13)
at D:\Code\NodeJs\uppy-test\app.js:18547:11
at new Promise ()
at D:\Code\NodeJs\uppy-test\app.js:18539:16
}
[Uppy] [02:26:54] tus: failed to create upload, caused by TypeError: Cannot set properties of null (setting ‘withCredentials’), originated from request (method: POST, url: http://192.168.100.104/api/files, response code: n/a, response text: n/a, request id: n/a)
[Uppy] [02:26:54] Error: Failed to upload backup.sql
at Function. (D:\Code\NodeJs\uppy-test\app.js:33790:24)
at emitAll (D:\Code\NodeJs\uppy-test\app.js:16869:18)
at Object.emit (D:\Code\NodeJs\uppy-test\app.js:16814:11)
at _Uppy.emit (D:\Code\NodeJs\uppy-test\app.js:32702:60)
at D:\Code\NodeJs\uppy-test\app.js:34940:15
at async Promise.allSettled (index 0)
at async Tus._uploadFiles2 (D:\Code\NodeJs\uppy-test\app.js:34969:3)
at async value (D:\Code\NodeJs\uppy-test\app.js:34655:9)
at async _Uppy._runUpload2 (D:\Code\NodeJs\uppy-test\app.js:34017:7)
at async goNode (D:\Code\NodeJs\uppy-test\app.js:35103:5) {
isUserFacing: true,
details: “tus: failed to create upload, caused by TypeError: Cannot set properties of null (setting ‘withCredentials’), originated from request (method: POST, url: http://192.168.100.104/api/files, response code: n/a, response text: n/a, request id: n/a)”
}

Hello, Uppy is designed for use in browsers and does not work inside Node.js. If you want to upload files in Node.js to your tus server, you can use tus-js-client directly. That is the same client that Uppy uses for tus uploads.

It’s a bit sad, but I understand. Thanks for the answer :slightly_smiling_face: