Non-256KiB chunk size multiple Error direct creator upload using TUS

I’m trying to do direct creator uploads using TUS.
I get the following error message and it doesn’t work.

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10031,
      "message": "Non-256KiB chunk size multiple"
    }
  ],
  "messages": null
}

I am using tus-js-client and the code is as follows

    const videoRes = await fetch(videoPath);
    const blob = await videoRes.blob();

    const upload = new Upload(blob, {
      endpoint,
      chunkSize: 5242880,
      metadata: {
        filename: "testvideoname",
        filetype: blob.type,
      },
      onError: (error) => {
        console.log(error);
      },
      onProgress: (bytesUploaded, bytesTotal) => {
        var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
        console.log(bytesUploaded, bytesTotal, percentage + "%");
      },
      onSuccess: () => {
        console.log("Download %s from %s", upload.file.name, upload.url);
      },
    });

I’m using one-time upload URL as endpoint

I thought it was because the file size to be uploaded was smaller than the chunk size that I had set, but it worked when I used the following API with the same settings to upload.

https://api.cloudflare.com/client/v4/accounts/{ACCOUNT ID}/stream

What is the problem?

If you are using one-time uploads feature, can you confirm that you have created your own endpoint that calls the Stream API request the one-time upload URL? You can find an example here: https://developers.cloudflare.com/stream/uploading-videos/direct-creator-uploads#using-tus-recommended-for-videos-over-200mb

The code to get the the one-time upload URL is below

import type { NextApiRequest, NextApiResponse } from "next";

const getTmpUploadUrl = async (req: NextApiRequest, res: NextApiResponse) => {
  try {
    const uploadLength = req.headers["upload-length"];
    const uploadMetadata = req.headers["upload-metadata"];
    if (!uploadLength || !uploadMetadata || typeof uploadLength !== "string" || typeof uploadMetadata !== "string") {
      return res.status(400).json({ result: "ng", message: "invalid header." });
    }
    const response = await fetch(
      `https://api.cloudflare.com/client/v4/accounts/${process.env.CLOUDFLARE_ACCOUNT_ID}/stream?direct_user=true`,
      {
        method: "POST",
        headers: {
          Authorization: `bearer ${process.env.CLOUDFLARE_SECRET_TOKEN}`,
          "Tus-Resumable": "1.0.0",
          "Upload-Length": uploadLength,
          "Upload-Metadata": uploadMetadata,
        },
      }
    );

    const destination = response.headers.get("Location");
		if (!destination) return res.status(500).json({result: "ng", message: "Location Header is null."});

		res.setHeader("Location", destination);
    return res.status(200).json({ result: "ok" });
  } catch (error) {
    console.error(error);
    return res.status(500).json({ result: "ng", message: "unexpected error." });
  }
};

export default getTmpUploadUrl;

And an example of one-time upload URL is below

https://upload.videodelivery.net/tus/6f173a0951ef1280de46f4adc5277f64?tusv2=true

I misunderstood the specification of the endpoint.
I should have specified the endpoint of the API I created.