'broadcasting/auth' - XMLHttpRequest issue for flutter for web app[Pusher] - how fix?

32 views Asked by At

I wrote my own chat using pusher-channels-flutter. It was quite difficult - now it works - but there is a problem.

The architecture is as follows:

  • mobile application flutter

  • web app -flutter for web

  • between them the Laravel server part

it all works when i run web app with the "--disable-web-security" flag. Otherwise, I get a 403 error when request "broadcasting/auth" - I see the following message in the console.

:53050/#/login:1 Access to XMLHttpRequest at 'https://example.com/broadcasting/auth'

from origin 'http://localhost:53050' has been blocked by CORS policy: Request header 

field authorization is not allowed by Access-Control-Allow-Headers in preflight response

I set up CORS on the server - very loyal rules

return [


    'paths' => ['api/*', 'sanctum/csrf-cookie', 'uploads/*',  "broadcasting/auth" ],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],
    //'allowed_headers' => ['Content-Type', 'X-Requested-With', 'Authorization'],

    'exposed_headers' => [],

    'max_age' => 0,

    'supports_credentials' => false,

];

if I use postman - the query works without problems. How can this be fixed? Any advice I'd appreciate - this problem has taken a long time.

0

There are 0 answers