I'm working on a resumable video upload feature to YouTube using their API, and I'm encountering a specific problem with CORS (Cross-Origin Resource Sharing).Context:
Frontend: My frontend is written in JavaScript (using the Fetch API) and initializes the uploads.
Backend: My backend (Symfony) generates the resumable upload URL by calling the YouTube API and returns this URL to the frontend.
Upload: The frontend uses this URL to upload chunks directly to YouTube. Everything works perfectly until about 96% of the upload is completed.
Problem:
During the last chunk (around 96% progress), I receive a CORS-related error:
The response body is not accessible to scripts (reason: CORS Missing Allow Origin).
This seems to indicate that the YouTube API is not returning the expected Access-Control-Allow-Origin headers.Observations:
When I handle everything on the frontend (initializing the upload and sending chunks), it works perfectly until the end.
When I use the URL generated by my backend, the issue arises only during the last request (finalizing the upload).
Note: I chose to handle the upload on the frontend to avoid overloading my server with potentially large files.Suggestions Needed:
Do you have any suggestions to work around or resolve this issue, please?Another Small Question:
The YouTube API allows only 10,000 quota units per day, but video uploads consume 1,600 units each. This quickly becomes a bottleneck during development, as I don’t have much room to test.
Do you know of any solutions to test uploads without consuming units, if possible?
Problem:
During the last chunk (around 96% progress), I receive a CORS-related error:
The response body is not accessible to scripts (reason: CORS Missing Allow Origin).
This seems to indicate that the YouTube API is not returning the expected Access-Control-Allow-Origin headers.Observations:
When I handle everything on the frontend (initializing the upload and sending chunks), it works perfectly until the end.
When I use the URL generated by my backend, the issue arises only during the last request (finalizing the upload).