TUS upload api fails

Hi fellow programmers,

We are using Angular framework as frontend and Nodejs as Backend to implement Direct Creator Upload method. Tried generating one-time upload url and passed it from upload method in angular like below.

onUpload(e) {
    console.log("on upload", e)
    // Get the selected file from the input element
    var file = e.target.files[0]

    // Create a new tus upload
    var upload = new tus.Upload(file, {
      // Endpoint is the upload creation URL from your tus server
      endpoint: "http://localhost:1337/cloudflare/upload",
      // Retry delays will enable tus-js-client to automatically retry on errors
      retryDelays: [0, 3000, 5000],
      // Attach additional meta data about the file for the server
      metadata: {
        filename: file.name,
        filetype: file.type
      // Callback for errors which cannot be fixed using retries
      onError: function (error) {
        console.log("Failed because: " + error)
      // Callback for reporting upload progress
      onProgress: function (bytesUploaded, bytesTotal) {
        var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
        console.log(bytesUploaded, bytesTotal, percentage + "%")
      // Callback for once the upload is completed
      onSuccess: function () {
        // console.log("Download %s from %s", upload.file.name, upload.url)

    // Check if there are any previous uploads to continue.
    upload.findPreviousUploads().then(function (previousUploads) {
      // Found previous uploads so we select the first one. 
      if (previousUploads.length) {

      // Start the upload

The url given above in the endpoint key, provides our server api url returning the one-time tokenized url in “location” key as suggested by many people in the community for those who faced similar issues. However, it still did not work and we were getting the error below.

Failed because: Error: tus: failed to create upload, caused by [object ProgressEvent], originated from request (method: POST, url: http://localhost:1337/cloudflare/upload, response code: n/a, response text: n/a, request id: n/a)

Please guide us on how to proceed. The code that we wrote in nodejs is as below.