1

KMS+OPENVIDU サーバーを docker で起動します。JQ ajaxを使用すると、すべてがWebコンポーネントでうまく機能します。

例(これはうまくいきます):

   $.ajax({
          type: "POST",
          url: OPENVIDU_SERVER_URL + "/api/sessions",
          data: JSON.stringify({ customSessionId: sessionId }),
          headers: {
            "Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
            "Content-Type": "application/json"
          },
          success: response => resolve(response.data.id),
          error: (error) => {
            if (error.status === 409) {
              resolve(sessionId);
            } else {
              console.warn('No connection to OpenVidu Server. This may be a certificate error at ' + OPENVIDU_SERVER_URL);
              if (window.confirm('No connection to OpenVidu Server. This may be a certificate error at \"' + OPENVIDU_SERVER_URL + '\"\n\nClick OK to navigate and accept it. ' +
                'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' + OPENVIDU_SERVER_URL + '"')) {
                location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
              }
            }
          }
        })

fetch (ネイティブ javascript) を入れた場合:

      var myPromise = fetch(this.ovServerUrl + '/api/sessions', {
        method: 'POST',
        // mode: 'cors',
        // credentials: 'same-origin',
        // redirect: 'follow',
        body: JSON.stringify(
          { customSessionId: sessionId }
        ),
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Basic ' + btoa('OPENVIDUAPP:' + this.ovSecret)
        }
      })


      return myPromise.then(response => {
        console.log('return resolve !response', response)
        console.log('return resolve !response.data.id! ', response.data.id)
        return response.id
      })

応答はありましたが、ありませんresponse.idでした。

次のように見えます:

body: (...)
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: ""
type: "cors"
url: "https://MY_DOMAIN:4443/api/sessions"

なにか提案を ?

4

0 に答える 0