Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I resolve problems with https in MoonShine


How do I resolve problems with https in MoonShine


To resolve HTTPS issues in MoonShine, follow these steps:

1. SSL Certificate: Ensure you have a valid SSL certificate installed on your server. This is crucial for enabling HTTPS.

2. TrustProxies Middleware: Update the `TrustProxies` middleware in your Laravel application. Set the `$proxies` property to `['*']` to trust all proxies, which is helpful if your application is behind a load balancer or a reverse proxy that handles SSL termination[1].

3. APP_URL Configuration: Check your `.env` file to ensure the `APP_URL` is set to use HTTPS. For example:


   APP_URL=https://yourdomain.com
   

4. Force HTTPS in Routes: If necessary, you can force HTTPS in your routes by using middleware. You can add the following to your `App\Http\Middleware\RedirectIfAuthenticated` or create a new middleware:

php
   public function handle($request, Closure $next)
   {
       if (!$request->secure()) {
           return redirect()->secure($request->getRequestUri());
       }
       return $next($request);
   }
   

5. Clear Cache: After making changes, clear your application's cache to ensure that the new settings take effect. Run:


   php artisan config:cache
   php artisan route:cache
   

By following these steps, you should be able to resolve HTTPS-related issues in your MoonShine application[1].

Citations:
[1] https://moonshine-laravel.com/docs/resource/getting-started/troubleshooting
[2] https://github.com/Moonshine-IDE/Moonshine-IDE/issues/49
[3] https://moonshine.cutcode.dev/section/contribution
[4] https://www.youtube.com/watch?v=fCGEd87ieEQ
[5] https://www.youtube.com/watch?v=0IyzwluNXBU
[6] https://www.reddit.com/r/RedDeadOnline/comments/eaye8d/moonshiner_bug_report_possible_solutions_thread/
[7] https://github.com/moonshine-software
[8] https://github.com/moonshine-software/moonshine