thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

CSP non-secured content not loading when using SSL #5513

Closed notcoderguy closed 2 years ago

notcoderguy commented 2 years ago

Laravel version

8.75

PHP version

7.4.3

Voyager version

1.5.2

Database

MySQL 8.0.27

Description

The TinyMCE is not loading as the necessary scripts are giving CSP errors. The file manager is also loading infinitely.

Steps to reproduce

[1] Create a new project. [2] Install voyager with dummy data. [3] Make sure to serve securely.

Expected behavior

Load TinyMCE editor and show File Manager without any errors.

Screenshots

error1 error2 error3

Additional context

When accessing the website via unsecured channel everything is loading normally but I have to disable the SSL for the whole website which I don't want.

I know that this helper function is giving us the links to the assets and I tried to resolve the problem via this but I was unable to get the desired result as no CSS and JS were loaded as MIME types were not assigned to them with my method.

if (!function_exists('voyager_asset')) { function voyager_asset($path, $secure = null) { return route('voyager.voyager_assets').'?path='.urlencode($path); } }

notcoderguy commented 2 years ago

Forcing URL to HTTPS in AppServiceProvider resolved the issue.

        if($this->app->environment('production')) {
            \URL::forceScheme('https');
        }
fletch3555 commented 2 years ago

This is usually because laravel isn't seeing an HTTPS request. Many reasons for that, but they all boil down to TLS terminating early (i.e. at cloudflare or similar) and not having trusted proxy configured properly

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.