当前位置: 首页 > 知识库问答 >
问题:

响应中'Access-Control-Allow-Credentials'标头的值为'',当请求的凭据模式为'Include'时,该值必须为'true'

西门振
2023-03-14
XMLHttpRequest cannot load http://sitename.net/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%5D&_=1501957673711. The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:35609' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
 app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);
            var hubConfiguration = new HubConfiguration {};
            hubConfiguration.EnableJSONP = true;
            map.RunSignalR(hubConfiguration);

        });
var cors = new EnableCorsAttribute("*", "*", "*")
        {
            SupportsCredentials = true
        };
        config.EnableCors(cors);
 var connection = null;
this.initialize = function () {
    connection = $.hubConnection("http://name.azurewebsites.net/signalr"{ useDefaultPath: false });
    this.proxy = connection.createHubProxy('myHub');
   connection.start().done(function () {
        console.log("started");
    }).fail(function (result) {
        console.log(result);
    });
};

共有1个答案

谭研
2023-03-14

我们可以从Azure Portal为Azure应用程序服务设置CORS。更多详细信息请参阅如何在Azure应用服务中配置CORS。

应用程序服务提供了对跨源资源共享(CORS)的内置支持,它使JavaScript客户端能够对API应用程序中托管的API进行跨域调用

文件截图:

 类似资料: