當我將我的 Laravel 專案上傳到 Heroku 主機并轉到主頁時,我發現 Laravel 主頁(welcome.blade.php)很好,但是當我嘗試其中一條路線時,我得到一個頁面,上面寫著 NOT FOUND 現在我已經編輯了我的 Procfile 將我重定向到路由檔案夾,然后當我嘗試其中一個 api 路由時,收到此訊息在此服務器上找不到請求的 URL。
我在本地服務器上嘗試了這條路線并且它有效
我的 Procfile :
web: vendor/bin/heroku-php-apache2 routes/
我的 api 檔案:
Route::post('/users/register' , 'App\Http\Controllers\AuthController@register') ;
我的 .env 檔案
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:PecXeFHeAtspGD2s79k4F5HNh2mwgJEC7B1j7/a5cPU=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=storeappdb
DB_USERNAME=root
DB_PASSWORD=
我的database.php檔案
$DATABASE_URL=parse_url("uaodyzzuglhswm:f3e63e876b4eb6ffde66a69e7cc2942d639d0a98ad8107e5ab262c7219efc92d@ec2-54-164-241-193.compute-1.amazonaws.com:5432/d5jmfh2osra85q");
'default' => env('DB_CONNECTION', 'pgsql'),
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => $DATABASE_URL['host'] ,
'port' => $DATABASE_URL['port'] ,
'database' => ltrim($DATABASE_URL['path'] , "/"),
'username' => $DATABASE_URL['user'],
'password' => $DATABASE_URL['pass'],
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
uj5u.com熱心網友回復:
您的檔案根目錄應該是public您的應用程式的檔案夾。所以你的“Procfile”需要反映:
web: vendor/bin/heroku-php-apache2 public/
檔案根目錄設定為public檔案夾,因為您的應用程式唯一可訪問的部分是其中的內容public(因此名稱為“公共”)。中的index.php檔案public是應用程式(前端加載程式或前端控制器)的入口點。網路服務器將在內部重寫 URL 以傳遞給此腳本(這是其中的.htaccess檔案public正在設定的內容)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/402791.html
標籤:
上一篇:處理bash腳本中的特殊字符
