gpt4 book ai didi

c# - Azure 中没有 'Access-Control-Allow-Origin' header

转载 作者:行者123 更新时间:2023-12-03 01:05:15 25 4
gpt4 key购买 nike

我有一个 Azure API 应用服务。我已将 * 添加到其中的 CORS 设置。

我在 Azure 中有另一个 Web 应用程序,我可以在其中调用 Azure API 应用程序。

示例:https://XXXXXX.XXXXXX.net/api/XXXXXX

当 API 处理小视频文件时,这些调用可以工作,但每当视频超过 20mb 时,我总是会得到 -

No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:9000' is therefore not allowed access.
The response had HTTP status code 500

API 接受来自 POST 请求的 ID,并处理 Azure 媒体存储中文件夹中的视频。当视频小于 20mb 时,不会发生此错误。

知道问题出在哪里吗?

我不断得到

500 - 请求超时。网络服务器未能在指定时间内响应。作为响应和控制台上的 CORS 错误。

API 调用可以正常工作并完成其工作。

这是 web.config 的样子

<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" maxRequestLength="5097151" executionTimeout="1800" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>

<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="5097151000"/>
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<httpProtocol>

</httpProtocol>
</system.webServer>

最佳答案

没有返回 CORS header ,因为响应是 HTTP 500,很可能是由于负载超出了允许的最大大小。

使用更大的值修改您的web.config:

<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="{value In Bytes}"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>

From MSDN (强调我的)-

maxAllowedContentLength

Optional uint attribute. Specifies the maximum length of content in a request, in bytes. The default value is 30000000, which is approximately 28.6MB.

关于c# - Azure 中没有 'Access-Control-Allow-Origin' header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50152519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com