0

I'm trying to implement facebook auth using SPA - Angular 6 and backend API - Laravel with Dingo/API.

When I try to redirect and return to SPA the page

public function redirectToProvider()
    {
        return Socialite::driver('facebook')->stateless()->redirect()->getTargetUrl();
    }

By some reason response comes from http instead of https according to error.

[blocked] The page at https://www.domain/ was not allowed to display insecure content from http://api.domain/auth/facebook.

Although, I've set up my domains both to be on https and redirect all http requests to https. Moreover, I'm calling https://api.domain/auth/facebook with GET method.

Sergey
  • 7,184
  • 13
  • 42
  • 85
  • did you checked your redirect url specified in either your route file or in your developer console of facebook – HexaCrop Sep 07 '18 at 10:48
  • indeed. It also uses https. Moreover, I've specified that is set is up so that http requests are redirected to https – Sergey Sep 07 '18 at 12:10

1 Answers1

0

As I mentioned in another question, there are few ways to make laravel work using https protocol:

  1. Configure your web server to redirect all non-secure requests to https. Example of a nginx config:

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name example.com www.example.com;
        return 301 https://example.com$request_uri;
    }
    
  2. Set your environment variable APP_URL using https:

    APP_URL=https://example.com
    
  3. Use helper secure_url() (Laravel5.6)

  4. Add following string to AppServiceProvider::boot() method (for version 5.4+):

    \Illuminate\Support\Facades\URL::forceScheme('https');
    
  5. Implicitly setting scheme for route group (Laravel5.6):

    Route::group(['scheme' => 'https'], function () {
        // Route::get(...)->name(...);
    });
    
Prisacari Dmitrii
  • 1,985
  • 1
  • 23
  • 33