Fix production 500 error: remove build-time config:cache and fix runtime database permissions and seeding
This commit is contained in:
@@ -4,7 +4,54 @@ use App\Http\Controllers\Admin\MakerWorldController;
|
||||
use App\Http\Controllers\CartController;
|
||||
use App\Http\Controllers\CheckoutController;
|
||||
use App\Http\Controllers\ShopController;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// Health & Diagnostics
|
||||
Route::get('/health-debug', function () {
|
||||
$dbPath = config('database.connections.sqlite.database');
|
||||
|
||||
$diagnostics = [
|
||||
'php_version' => PHP_VERSION,
|
||||
'app_env' => config('app.env'),
|
||||
'has_app_key' => ! empty(config('app.key')),
|
||||
'app_key_len' => strlen((string) config('app.key')),
|
||||
'db_connection' => config('database.default'),
|
||||
'db_path' => $dbPath,
|
||||
'db_file_exists' => is_string($dbPath) && file_exists($dbPath),
|
||||
'db_dir_writable' => is_string($dbPath) && is_writable(dirname($dbPath)),
|
||||
];
|
||||
|
||||
try {
|
||||
DB::connection()->getPdo();
|
||||
$diagnostics['db_pdo'] = 'CONNECTED';
|
||||
$diagnostics['tables'] = Schema::getTableListing();
|
||||
} catch (Throwable $e) {
|
||||
$diagnostics['db_pdo_error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$diagnostics['categories_count'] = Category::count();
|
||||
} catch (Throwable $e) {
|
||||
$diagnostics['categories_error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$diagnostics['products_count'] = Product::count();
|
||||
} catch (Throwable $e) {
|
||||
$diagnostics['products_error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($diagnostics);
|
||||
})->withoutMiddleware([
|
||||
StartSession::class,
|
||||
EncryptCookies::class,
|
||||
]);
|
||||
|
||||
// Shop & Product routes
|
||||
Route::get('/', [ShopController::class, 'index'])->name('home');
|
||||
|
||||
Reference in New Issue
Block a user