dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

cors error and laravel-cors #1551

Closed gotoin closed 6 years ago

gotoin commented 6 years ago
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.5
Package version 2.0.0
PHP version 7.1

Actual Behaviour

response headers
Access-Control-Allow-Origin: 

Expected Behaviour

response headers
Access-Control-Allow-Origin: *

Steps to Reproduce

// config/api.php
'middleware' => [
        \Barryvdh\Cors\HandleCors::class,
    ],
// Kernel.php

'api' => [
            'throttle:60,1',
            'bindings',
             \Barryvdh\Cors\HandleCors::class,
],

Possible Solutions

first delete laravel-cors

// add it to config/api.php
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:*');
header('Access-Control-Allow-Methods:*');
header('Access-Control-Allow-Credentials:false');
header('withCredentials:false');

But this is not an elegant solution.

thanks.

erayaydin commented 6 years ago

Tested with Fresh Laravel Installation(Laravel5.5+Dingo2.0), CORS working. Are you published config/cors.php ?

gotoin commented 6 years ago

I use the laravel-cors package. and that problem with this package.

thank you.

@erayaydin