drodsh7940 2016-12-17 17:01
浏览 190
已采纳

Laravel新API不起作用

I'm trying to learn Laravel (5.3.28) and I'm running into an issue with my very first api route not working. I've followed the Laravel docs and can create a new project and can navigate to the Laravel splash screen indicating it's working. I added the following route to routes/api.php to test if I can consume the end-point, but I get an error:

routes/api.php

Route::get('foo', function () {
    return 'Hello World';
});

error

NotFoundHttpException in RouteCollection.php line 161:

I have a dedicated CentOS box running XAMPP for my web server. the address to hit the end-point is http://10.0.0.200/test/api/public/foo.

I'm read that my .htaccess file should be edited, but the few examples I found match what I already have, so I'm a little lost on what to do.

Here is the output for php artisan route:list:

+--------+----------+----------+------+---------+--------------+
| Domain | Method   | URI      | Name | Action  | Middleware   |
+--------+----------+----------+------+---------+--------------+
|        | GET|HEAD | /        |      | Closure | web          |
|        | GET|HEAD | api/foo  |      | Closure | api          |
|        | GET|HEAD | api/user |      | Closure | api,auth:api |
+--------+----------+----------+------+---------+--------------+
  • 写回答

2条回答 默认 最新

  • duanpie2414 2016-12-17 17:43
    关注

    10.0.0.200/test/api/public is the root URL I assume. If yes, then you need to hit 10.0.0.200/test/api/public/api/foo

    I think that your project lies in the folder test/api, what you need is to reconfigure apache ginx to route all requests going to 10.0.0.200/test/ , to start going to {webser root}/test/api/public . This is done in web server configuration files

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?