找不到 Laravel API 路由
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51428542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel API Route Not Found
提问by danielrvt
I'm trying to test an API route, but I always get 404 Not Found
.
我正在尝试测试 API 路由,但我总是得到404 Not Found
.
I'm using this command:
我正在使用这个命令:
curl http://localhost:8000/api/veip
This is my routes/api.php
这是我的 routes/api.php
<?php
use Illuminate\Http\Request;
Route::get('/veip', function () {
return 'Hello World';
});
And this is my php artisan route:list
output:
这是我的php artisan route:list
输出:
+--------+----------+----------+------+---------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+---------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/veip | | Closure | api |
+--------+----------+----------+------+---------+------------+
So the route does exists
所以路线确实存在
I don't know what's going on here...
我不知道这里发生了什么......
回答by Lakshmi
Run sudo a2enmod rewrite
to enable the mod_rewrite on the .htaccess file, then sudo service apache2 restart
运行sudo a2enmod rewrite
以启用 .htaccess 文件上的 mod_rewrite,然后sudo service apache2 restart
回答by Alenko Verzina
you need to call http ://my_localhost_link/api/someroute.
你需要调用 http://my_localhost_link/ api/someroute。
回答by aditiadika
try php artisan route:clear may work for you
试试 php artisan route:clear 可能对你有用
回答by benji127
You need to search Api/routes using: php artisan api:routes (artisan command) instead of php artisan route:list.
您需要使用以下命令搜索 Api/routes:php artisan api:routes(工匠命令)而不是 php artisan route:list。