ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP Stream supports CROS cross-domain

winlinvip opened this issue · comments

Reference: #691, Add crossdomain support in http_remux and hls for HTML5 playback.

TRANS_BY_GPT3

HTTP API automatically supports CROS (Cross-Origin Resource Sharing) for convenient access by JavaScript. If HTTP Stream needs to support MSE (Media Source Extensions), it also needs to support JavaScript access, which means supporting CROS cross-origin.

TRANS_BY_GPT3

Already supported, but I couldn't make it work in chrome54. I guess it's because I'm not using the correct way to initiate the xhr request. You can give it a try, it's added in 3.0.9.

TRANS_BY_GPT3

Before the refinement, the changes can be found here: https://github.com/ossrs/srs/pull/691/files

After the refinement, the changes can be found here: b231550

First refactor, improving existing API's CORS: f30b307

Second refactor, removing HLS RAM: 664844b

With less code, achieve more comprehensive functionality. The latter also supports reload, and the configuration file has been updated.

If we count the two refactors, the latter will definitely have more code than the former, but refactor is not directly related to adding new functionality; it improves the existing code.

Therefore, it is recommended to perform necessary refactoring before adding new functionality.

TRANS_BY_GPT3

Dup to #717 #798 #1002 #1025

image

image

Note that if Nginx has set the cross-origin header, SRS3 will also set it once, which will cause this error. This means that there are two cross-origin headers, which can be disabled in SRS3 by turning off CORS.

http_server {
    crossdomain off;
}

Alternatively, you can remove this header setting from Nginx or use more_set_headers.

TRANS_BY_GPT3

What should I do with 'srs2'?

TRANS_BY_GPT3