Laravel 5.5 Error 405 (Method Not Allowed) XHR PUT METHOD now working on Azure Server

大兔子大兔子 提交于 2021-02-08 10:26:25

问题


I have installed Laravel 5.5 on Azure Web Server with PHP 7 installed. Other request methods working well except the XHR PUT METHOD. It returns an error message on the console: 405 (Method Not Allowed) and XHR network preview: The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

I already allowed the PUT method on web.config files

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
 <system.webServer>
 <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/>
 <staticContent>
 <remove fileExtension=".svg" />
 <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
 <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
 <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
 </staticContent>
 <httpProtocol>
 <customHeaders>
 <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
 <add name="Access-Control-Allow-Origin" value="*" />
 <add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
 <add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
 </customHeaders>
 </httpProtocol>
 <rewrite>
 <rules>
 <rule name="Laravel5" stopProcessing="true">
 <match url="^" ignoreCase="false" />
 <conditions logicalGrouping="MatchAll">
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php" appendQueryString="true" />
 </rule>
 </rules>
 </rewrite>
 <security>
      <requestFiltering>
        <requestLimits maxQueryString="10000" />
      </requestFiltering>
    </security>
 </system.webServer>
</configuration>

Please kindly help me. Thanks


回答1:


I have found the answer, by this question. stackoverflow.com/a/25171782/2544756 by adding this code to system.Webserver

<handlers>
    <remove name="PHP71_via_FastCGI" />
    <add name="PHP71_via_FastCGI" path="*.php" verb="GET,PUT,POST,DELETE,HEAD,OPTIONS,TRACE,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v7.1\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>

But I need to change the PHP version to 7.1 Hope it



来源:https://stackoverflow.com/questions/52397597/laravel-5-5-error-405-method-not-allowed-xhr-put-method-now-working-on-azure-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!