When I uploaded my laravel project to Heroku host and go to the home page I found the laravel homepage (welcome.blade.php) that is fine but when a try one of my routes I get a page that says NOT FOUND now i have edited my Procfile to redirect me to routes folder then when I try one of my api routes a get this message The requested URL was not found on this server.
I tried this route on local server and it works
my Procfile :
web: vendor/bin/heroku-php-apache2 routes/
my api file :
Route::post('/users/register' , 'App\Http\Controllers\AuthController@register') ;
my .env file
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=
my database.php file
$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',
],
CodePudding user response:
Your document root is supposed to be the public
folder of your application. So your "Procfile" needs to reflect that:
web: vendor/bin/heroku-php-apache2 public/
The document root is set to the public
folder because the only accessible part of your application is what is in public
(hence the name 'public'). The index.php
file in public
is the entry point to your application (Front Loader or Front Controller). The webserver will internally rewrite the URLs to pass off to this script (which is what the .htaccess
file in public
is setting up).