CDN-server | placeholder text - | Data Manipulation library
kandi X-RAY | CDN-server Summary
kandi X-RAY | CDN-server Summary
placeholder text
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CDN-server
CDN-server Key Features
CDN-server Examples and Code Snippets
Community Discussions
Trending Discussions on CDN-server
QUESTION
I'm trying to use the hls.js library for displaying Reddit hosted videos from the HLS/DASH playlist. However, accessing any Reddit HLS/DASH url, such as this one through XHR will fail due to, what the error says is a Same Origin Policy violation:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://v.redd.it/5r0nz8sywgl41/DASHPlaylist.mpd. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Weird thing is, the request prior GET is an OPTIONS one, which does return the Access-Control-Allow-Origin header with the correct origin url. I can see the response in the developer console, but the request still "fails". If I use the "Allow CORS: Access-Control-Allow-Origin" extension, everything works fine. What am I doing incorrectly?
OPTIONS request headers:
...ANSWER
Answered 2020-Mar-10 at 02:59The problem is just: the response from https://v.redd.it/5r0nz8sywgl41/DASHPlaylist.mpd
to the GET
request from your code doesn’t include the Access-Control-Allow-Origin
response header. Strangely though, it does include the Access-Control-Expose-Headers
response header. So the cause is just that the server is misconfigured; it’s not actually properly CORS-enabled.
Specifically: even though the server sends a Access-Control-Allow-Origin
header in response to the OPTIONS
preflight, that on its own isn’t sufficient to make browsers allow your frontend code to access the response to the actual GET
request in your code. For your code to work, the server must also send the Access-Control-Allow-Origin
header in response to that GET
request too.
But you can actually work around the https://v.redd.it
misconfiguration and access Reddit HLS/DASH URLs from your frontend code without needing a browser extension — by making your request through CORS proxy, as in the following example.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CDN-server
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page