我厌倦了所有浏览器中的以下问题
\n\nCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://vid-129002.hls.chinanetcenter.broadcastapp.agoraio.cn/live/pub421490684319281/playlist.m3u8. (Reason: CORS header \xe2\x80\x98Access-Control-Allow-Origin\xe2\x80\x99 missing)\nRun Code Online (Sandbox Code Playgroud)\n\n我在 Node js 之上使用了 Reactjs 和 Express。在这里,我尝试从 Agora 服务器播放直播视频,但它没有播放。当我检查控制台时,显示了上述错误。我尝试了一些 Cors 插件到 chrome,它工作得很好。\n我们如何通过直接在express-react环境中添加此标头来解决这个问题?
\n\n从一些教程中我添加了以下内容来解决它:
\n\nvar config = {\nentry: APP_DIR + \'/index.jsx\',\nheaders: {\n "Access-Control-Allow-Origin": "http://localhost:3000",\n "Access-Control-Allow-Credentials": "true",\n "Access-Control-Allow-Headers": "Content-Type, Authorization, x-id, \n Content-Length, X-Requested-With",\n "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS"\n},\nRun Code Online (Sandbox Code Playgroud)\n\n我的 server.js 文件:
\n\n var path = require(\'path\');\n var webpack = require(\'webpack\');\n var express = require(\'express\');\n var …Run Code Online (Sandbox Code Playgroud)