Mixed Content issue. Https
calgara12 opened this issue · 4 comments
Hey, first of all, thank you so much for making this awesome application.
I wanted to install this in docker, and luckily i found a fork, that already implemented this. So i spun up the container, i just added my traefik labels to make it accessible publicly.
When i tried to reach it locally through 192.168.1.178:6030 it worked, but, when i tried to access it through my domain https://flox.mydomain.com i got an empty page, and when i looked at the console with F12 it gave me these errors:
https://i.stack.imgur.com/pYk2t.png
Then i went ahead and changed the APP_URL from http://localhost to https://flox.mydomain.com in the .env file which gave me the same result.
Then after doing some research i tried to force https by editing /backend/app/Providers/AppServiceProvider.php
I added use Illuminate\Support\Facades\URL;
at the beginning of the file and URL::forceScheme('https');
inside the boot function.
This helped resolve all the above mentioned Errors and the Application finally loaded and i thought this would be the end of it. But that's not how the cookie crumbled.
I added a few movies to my watchlist, and then later when i looked at the list, not all movies loaded but there is a "Load more" button at the end of the website, and when i click that button, the old familliar "mixed content" error came back.
https://i.stack.imgur.com/KbVZZ.png
https://i.stack.imgur.com/2Wswd.png
I have no Idea why this is not served over https. Any help would be greatly appreciated! Thanks
Hey, I can't tell you why it's not working correctly on your machine :/
Could you also add URL::forceScheme('https');
to the top of your web.php
and test it?
Already did that. Unfortunately did not work.
Chrome says that the error comes from the vendor.js file. Not sure if that is right, cause that file is huge.
I've spend the last 2 days trying to figure this out, still no clue why this is happening. Do you have any idea where i could look, or ask for help?
EDIT:
Maybe this can be solved inside the .htaccess ?
Or would there be a workaround? Could i change the size of max number of items on a page, to a size that wouldn't cut off anything?
Thanks!
I solved it, FINALLY. However I don't know what in the end caused it to work. So ill just share everything I did:
backend/app/Providers/AppServiceProvider.php:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\URL;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app['request']->server->set('HTTPS', true);
URL::forceScheme('https');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
if (env('APP_ENV') === 'production') {
$this->app['request']->server->set('HTTPS', true);
}
}
}
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#ForceSSL
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} .
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Hope this helps someone who has the same problem!
@calgara12 where did you place the .htaccess file?