【问题标题】:Laravel API routes 404 not found fix?Laravel API 路由 404 未找到修复?
【发布时间】:2022-01-14 10:10:05
【问题描述】:

我刚刚上传了仅用于 API 的 Laravel 后端项目,但是当我从邮递员那里调用任何路由时,它显示 404 未找到,我无法捕捉到错误原因

Laravel api.php

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::post('/handle-register', 'App\Http\Controllers\ApiAuthController@handleRegister');
Route::post('/handle-login', 'App\Http\Controllers\ApiAuthController@handleLogin');

Route::get('/users', 'App\Http\Controllers\ApiUserController@index');
Route::post('/users-store', 'App\Http\Controllers\ApiUserController@store');

.htaccess 文件

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

【问题讨论】:

  • Welcome to SO ... 这是 Laravel 404 页面还是网络服务器 404 页面?
  • 请张贴您拨打的网址?

标签: laravel api backend


【解决方案1】:

有一些使用方法

  1. 使用 Apache
  2. 运行 laravel 服务器并在邮递员中使用服务器 URL

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2020-10-26
  • 2014-06-25
  • 1970-01-01
  • 1970-01-01
  • 2015-02-04
  • 2021-11-06
  • 2018-12-27
  • 2020-04-14
相关资源
最近更新 更多