fruitcake / laravel-cors

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
MIT License
6.27k stars 613 forks source link

CORS issue when using Quasar Mobile app #506

Closed Kirito70 closed 4 years ago

Kirito70 commented 4 years ago

We are having a CORS issue when we send a request using the quasar android emulator or a phone to a live server. If we use web SPA of the same application is works fine. We faced this issue after updating this package to latest the latest version. Before opening the issue, we have completed all of the steps provided above.

Here is core.php file ` return [

/*
|--------------------------------------------------------------------------
| Laravel CORS Options
|--------------------------------------------------------------------------
|
| The allowed_methods and allowed_headers options are case-insensitive.
|
| You don't need to provide both allowed_origins and allowed_origins_patterns.
| If one of the strings passed matches, it is considered a valid origin.
|
| If ['*'] is provided to allowed_methods, allowed_origins or allowed_headers
| all methods / origins / headers are allowed.
|
*/

/*
 * You can enable CORS for 1 or multiple paths.
 * Example: ['api/*']
 */
'paths' => ['api/*'],

/*
* Matches the request method. `['*']` allows all methods.
*/
'allowed_methods' => ['*'],

/*
 * Matches the request origin. `['*']` allows all origins. Wildcards can be used, eg `*.mydomain.com`
 */
'allowed_origins' => ['*'],

/*
 * Patterns that can be used with `preg_match` to match the origin.
 */
'allowed_origins_patterns' => [],

/*
 * Sets the Access-Control-Allow-Headers response header. `['*']` allows all headers.
 */
'allowed_headers' => ['*'],

/*
 * Sets the Access-Control-Expose-Headers response header with these headers.
 */
'exposed_headers' => [],

/*
 * Sets the Access-Control-Max-Age response header when > 0.
 */
'max_age' => 0,

/*
 * Sets the Access-Control-Allow-Credentials header.
 */
'supports_credentials' => true,

`

Here is the Response from Chrome dev tools

image

Please have a look. Thanks for you time.

stojankukrika commented 4 years ago

I have the same issue in production. In local works normally :(

gibrandev commented 4 years ago

in my case change 'paths' => ['api/*'], to 'paths' => ['*'], and work perfect.

Kirito70 commented 4 years ago

Got it working I think it was issue with cordova settings used this package and it worked like a charm maybe someone out there is having the same issue.

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/

Thanks for your time. Really appreciate it. Kind Regards, MT