TUS upload video problem

I send request to https://api.cloudflare.com/client/v4/accounts/<accountID>/stream?direct_user=true with curl in PHP, and get header location value as upload link then pass it to java Script.
this link is like this:
https://upload.videodelivery.net/tus/xxxxxx?tusv2=true

and in JS use tus.js for uploading video:

var file = document.querySelector('#video').files[0];

var options = {
        uploadUrl: 'https://upload.videodelivery.net/tus/xxxxxx?tusv2=true',
        chunkSize: 50 * 1024 * 1024,
        retryDelays: [0, 3000, 5000, 10000, 20000],
        parallelUploads: 1,
        metadata: {
            filename: file.name,
            filetype: file.type,
        },
        headers: {
            'Authorization': 'Bearer <Token>',
            'Tus-Resumable': '1.0.0'
        },
    }
    upload = new tus.Upload(file, options)
    upload.start();

but, requests was blocked.
what is solution?

Dear @zaid and @renan , can you help me?

@mirzaee.sh12 It seems to be that you are getting CORS errors. Your browser terminal should show what the exact issue is (your screenshot of the network tab cuts this error off in half).

Looking at your code I believe your issue is that you’re adding Authorization header, which is not needed in the second request. You don’t want to put your Cloudflare keys in the front end code that runs in the browsers of the users.

1 Like

thanks, problem was headers.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.