laravel - Laravel:通过 Axios 在 Azure 上为 DELETE 请求获取 405
问题描述
我已经在 Laravel 项目上工作了一段时间,不幸的是,在 Microsoft Azure 上托管的生产版本上发送 DELETE 请求时遇到了障碍。我发现问题是 Azure 默认拒绝我被定向到的 DELETE 请求:如何在 Azure 中启用 PUT 请求?. 但是,我已将 web.config 文件更新为以下内容:(服务器 PHP 版本 7.3,64 位)
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<handlers>
<remove name="PHP73_via_FastCGI" />
<add name="PHP73_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, DELETE" modules="FastCgiModule" scriptProcessor="D:\Program Files\PHP\v7.3\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我之前曾尝试运行此访问D:\Program Files (x86)
,但不幸的是,这也没有奏效。我已经发布了整个 web.config,因为我不确定添加的其他一些设置是否与尝试启用 DELETE 冲突。
作为参考,这里的路线被称为:
Route::group(['middleware' => ['auth']], function($router) {
Route::post('likes', 'LikesController@store');
Route::delete('likes/{', 'LikesController@remove');
Route::delete('likes/{like}', 'LikesController@remove');
});
调用LikesController@remove
仅运行$like->delete();
,然后返回没有已删除的类似评论的评论。
视图组件内部调用 axios 的方法:
axios.post('/api/likes', {comment_id: this.comment.id}).then((response) => {
this.comment = response.data;
}
我在本地构建上运行良好,所以我不确定为什么问题在提供的修复之外仍然存在。如果还有什么需要的,请告诉我,我会编辑帖子。
解决方案
推荐阅读
- c# - 在图像前面设置一个游戏对象
- css - Grid Container 不会占用完整的 vh
- javascript - 输入值已设置且可见,但在另一个脚本中无法访问
- powershell - 将管道参数绑定到函数参数时出现空错误
- scala - Scala 函数式编程和可变性
- visual-studio-code - vsCode 设置和切换编程语言
- python-3.x - tensorflow show ImportError: DLL load failed: %1 is not an valid Win32 application
- mysql - 另一个无法在 gcloud 中远程 mysql
- c# - Bot Framework 在对话之外读取 UserState 数据或恢复对话对话
- r - 如何通过 R 中的 For 循环创建许多线性回归模型?