Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brunojustino's avatar

No 'Access-Control-Allow-Origin' header is present on the requested resource

I have an api with laravel 5.4 and here is the cors class:

public function handle($request, Closure $next)
{
    return $next($request)
      ->header('Access-Control-Allow-Origin', '*')
      ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
}

and when I try to make a request with vue-resource on my aplication

this.$http.post(apiurl,data).then(response=>{
            console.log(response.body);
        })

I receive that I am not allowed to cross domain.

Thanks for the help

0 likes
3 replies
brunojustino's avatar

If someone have this problem, I solved using Vue.http.options.emulateJSON = true

1 like
Isma's avatar

Worked for me!!! Thank you very much!

Please or to participate in this conversation.