怒后不可便食,食后不可发怒。——梁章钜
文档
https://ossrs.net/lts/zh-cn/docs/v5/doc/http-api#authentication
1 2 3 4 5 6 7 8 9 10
| http_api { enabled on; listen 1985; auth { enabled on; username admin; password admin; } }
|
配置了之后如何访问?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| fetch("http://localhost:1985/api/v1/clients/", { "headers": { 'Authorization': 'Basic ' + btoa(`admin` + ":" + `admin`), "accept": "*/*", "accept-language": "zh-CN,zh;q=0.9", "content-type": "text/html", "sec-ch-ua": "\"Google Chrome\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" }, "referrerPolicy": "strict-origin-when-cross-origin", "body": null, "method": "GET", "mode": "cors", "credentials": "omit" });
|
bash:
1
| curl 'http://localhost:1985/api/v1/clients/' -H 'Authorization: Basic YWRtaW46YWRtaW4='
|