Lumen blocks only one route on CORS, all others work

Asked

Viewed 81 times

-2

I have a system that was working, but suddenly it stopped working. Giving error "No 'Access-Control-Allow-Origin' header is present on the requested Resource" Etou using Lumen with barryvdh/Laravel-Cors package, the whole site works except for a public form that gives me this error.

The request is made through Angular:

insert (data: Object) {
    let observable = this.http.post(this.url, data, this.requestOptions.merge(new RequestOptions()));
    return this.toPromise(observable);
}

In Lumen I receive the request through the route that forwards to this function:

 public function store(Request $request){
    $this->validate($request, $this->rules ?? [], $this->messages ?? []);
    $result = $this->model->create($request->all());
    return response()->json($result);
}

insira o código aqui

1 answer

-2

I was able to solve, it was a problem in the configuration of the email in Appservice Provider, because every time you enter a record an email is sent and was returning error in this configuration

    $this->app->configure('mail');
    $this->app->singleton('mailer', function(Application $app){
        $app->loadComponent('mail', MailServiceProvider::class, 'mailer');
    });

I switched to :

    $this->app->configure('mail');
    $this->app->alias('mailer',Mailer::class);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.