text/x-generic database.php ( PHP script, ASCII text ) 🧨 Cannot modify header information - headers already sent by (output started at /home/demoapijoss/public_html/config/database.php:1)
/home/demoapijoss/public_html/
ErrorException
Cannot modify header information - headers already sent by (output started at /home/demoapijoss/public_html/config/database.php:1)
    • 20
      app/Http/Middleware/cors.php
      Illuminate\Foundation\Bootstrap\HandleExceptions
      :20
  1. 1 unknown frame
    • 18
      app/Http/Middleware/cors.php
      App\Http\Middleware\cors
      :20
    • 1
      public/index.php
      :52
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
app/Http/Middleware/cors.php:20

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

use Closure;

use Illuminate\Http\Request;

 

class cors

{

/**

* Handle an incoming request.

*

* @param \Illuminate\Http\Request $request

* @param \Closure $next

* @return mixed

*/

public function handle(Request $request, Closure $next)

{

 

header("Access-Control-Allow-Origin: *");

//ALLOW OPTIONS METHOD

$headers = [

'Access-Control-Allow-Methods' => 'POST,GET,OPTIONS,PUT,DELETE',

'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin, Authorization',

];

if ($request->getMethod() == "OPTIONS"){

//The client-side application can set only headers allowed in Access-Control-Allow-Headers

return response()->json('OK',200,$headers);

}

$response = $next($request);

foreach ($headers as $key => $value) {

$response->header($key, $value);

}

return $response;