Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@
}
}

putenv('VERCEL=1');
$_ENV['VERCEL'] = '1';
$_SERVER['VERCEL'] = '1';
// Redirect cache bootstrap ke /tmp (karena /var/task/bootstrap/cache di Vercel itu read-only)
$envMappings = [
'VERCEL' => '1',
'APP_DEBUG' => 'true',
'SESSION_DRIVER' => 'cookie',
'CACHE_DRIVER' => 'array',
'LOG_CHANNEL' => 'stderr',
'VIEW_COMPILED_PATH' => '/tmp/views',
'APP_SERVICES_CACHE' => '/tmp/bootstrap/cache/services.php',
'APP_PACKAGES_CACHE' => '/tmp/bootstrap/cache/packages.php',
'APP_CONFIG_CACHE' => '/tmp/bootstrap/cache/config.php',
'APP_ROUTES_CACHE' => '/tmp/bootstrap/cache/routes.php',
'APP_EVENTS_CACHE' => '/tmp/bootstrap/cache/events.php',
];

putenv('VIEW_COMPILED_PATH=/tmp/views');
$_ENV['VIEW_COMPILED_PATH'] = '/tmp/views';
$_SERVER['VIEW_COMPILED_PATH'] = '/tmp/views';
foreach ($envMappings as $key => $val) {
putenv("{$key}={$val}");
$_ENV[$key] = $val;
$_SERVER[$key] = $val;
}

// Teruskan ke file public/index.php bawaan Laravel
require __DIR__ . '/../public/index.php';
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TrustProxies extends Middleware
*
* @var array<int, string>|string|null
*/
protected $proxies;
protected $proxies = '*';

/**
* The headers that should be used to detect proxies.
Expand Down
5 changes: 5 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Setting;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -22,6 +23,10 @@ public function register(): void
*/
public function boot(): void
{
if (config('app.env') === 'production' || isset($_SERVER['VERCEL']) || isset($_ENV['VERCEL'])) {
URL::forceScheme('https');
}

View::composer('*', function ($view) {
static $appSettings = null;

Expand Down
7 changes: 6 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
],
"env": {
"APP_ENV": "production",
"APP_DEBUG": "false",
"APP_DEBUG": "true",
"APP_CONFIG_CACHE": "/tmp/bootstrap/cache/config.php",
"APP_EVENTS_CACHE": "/tmp/bootstrap/cache/events.php",
"APP_PACKAGES_CACHE": "/tmp/bootstrap/cache/packages.php",
"APP_ROUTES_CACHE": "/tmp/bootstrap/cache/routes.php",
"APP_SERVICES_CACHE": "/tmp/bootstrap/cache/services.php",
"VIEW_COMPILED_PATH": "/tmp/views",
"CACHE_DRIVER": "array",
"LOG_CHANNEL": "stderr",
Expand Down