LiveNVR拉流视频流媒体平台如何解决JS_axios调用接口时遇到的跨域问题

@

1、JS调用遇到跨域解决示例

添加 xhrFields: { withCredentials: true},crossDomain: true,

$.ajax({
    type: "GET",
    url: "http://other-domain:10800/api/v1/login",
    xhrFields: { 
        withCredentials: true
    },
    crossDomain: true, 
    data: {
        username: 'test',
        password: 'test'
    },
    success: function(data) {
        console.log(data);
    }
})

2、axios请求接口遇到跨域问题

添加 withCredentials: true

2.1、post请求

 axios.post("http://ip:10800/api/v1/test", {
            param1: 'test',
            param2: 'test'
        }, {
            withCredentials: true
        }).then(res => {
            console.log(res)
        }).catch(err => {
            console.log(err);
        })

2.2、get请求

   axios.get("http://ip:10800/api/v1/test", {
            params:{start:0,limit:10},
            withCredentials: true
        }).then(res => {
            console.log(res)
        }).catch(err => {
            console.log(err);
        })

3、RTSP/HLS/FLV/RTMP拉流Onvif流媒体服务

posted @ 2022-06-30 15:37  Marvin1311  阅读(112)  评论(0编辑  收藏  举报