不允许使用纤薄框架方法.必须是以下之一:开机自检 (405)



我用纤薄的框架编写了REST api。当我从浏览器调用身份验证 API 时,它会通过"方法不允许。必须是以下之一:POST'。下面是我的代码,请纠正我出错的地方。

索引.php

<?php
require 'vendor/autoload.php';
require 'Authenticate.php';
$app = new SlimApp;
$app->post('/api/authenticate', Authenticate::class);
$app->run();

.htaccess

RewriteEngine On
RewriteRule ^ index.php [QSA,L]

网址

http://localhost/project/api/authenticate

如果您在浏览器中键入 URL,该方法将被GET而不是POST。你可以做的是使用Postman或你选择的其他替代方案来测试你的REST API的其他方法,如POSTPUTDELETE等。

有关 HTTP 方法的更多信息,请单击此处

希望对您有所帮助!

最新更新