geetpurwar
1 year ago

API returning 401

Posted 1 year ago by geetpurwar

Hi, I am trying to update content using JSON and Laravel API, however, its returning 401 now. What I need is just to pull this content and update database.

api.php

Route::post('/track_delivery', '[email protected]');

Route::options('{all}', '[email protected]')->where('all', '.*');

Route::any('{all}', function(){
    return abort(404);
})->where('all', '.*');

Notification Controller:

public function TrackDelivery(Request $request, Notification $notification)
{
    return "Track Delivery Count";
}

public function options(Request $request, Response $response)
{
        $origin = $request->header('origin') ?: $request->url();

        $response->header('Access-Control-Allow-Origin', $origin);
        $response->header('Access-Control-Allow-Headers', 'origin, content-type, accept, Authorizations');
        $response->header('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS, POST, PATCH, DELETE');

        return $response;
}

Any idea?

Please sign in or create an account to participate in this conversation.