1

I've got a problem with setting up Cors on Laravel.

Here is my middleware Cors.php:

public function handle($request, Closure $next)
{
    return $next($request)
        ->header('Access-Control-Allow-Origin', '*')
        ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
        ->header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, X-Token-Auth, Authorization');
}

I've tried within my rest client it working perfectly. I can see the headers. but when i tried to my front end (Angular) I don't get that response.

Error

Before this i use Cors Package by barryvdh but it still not support laravel 5.2

What should I add to make it working?

ssuhat
  • 7,387
  • 18
  • 61
  • 116
  • Are you able to paste the output of the following curl command? `curl -I -X GET http://192.168.10.10:443/v1/admin/auth/login` – Elliot Fehr Dec 26 '15 at 06:48
  • 2
    Hi, thanks for answering. It's working now. I put my middleware at wrong place. – ssuhat Dec 26 '15 at 06:51
  • That would explain it :) – Elliot Fehr Dec 26 '15 at 06:51
  • 2
    Possible duplicate of [Laravel cors 'Access-Control-Allow-Origin' and 'Access-Control-Allow-Headers'](https://stackoverflow.com/questions/37563350/laravel-cors-access-control-allow-origin-and-access-control-allow-headers) – Roham Rafii Feb 25 '18 at 17:58

0 Answers0