mcload's avatar

Routes not working

I have my route files set up. I would like to use api routes and it was working previously, I don't know what caused it to go down. This is my api routes file.

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post('/request-link', [RequestLinkController::class, '__invoke']);

Route::post('/statusUpdates', [StatusUpdateController::class, '__invoke']);

Route::post('/cancel-link', [CancelLinkController::class, '__invoke']);

Route::post('/retrieve-link', [HistoricalLinksController::class, '__invoke']);

Route::post('/refund-link', [RefundLinkController::class, '__invoke']);

Route::post('/merchant-refunds/confirm', [ConfirmRefundController::class, '__invoke']);

This is the error I'm getting on the api in postman:

"message": "The route api/refund-link could not be found.",
"exception": "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",
"file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php",
"line": 44,

I've cleared the route cache to no avail. I've checked the rewrite module and it's on (the whole stuff is running on a container in docker).

The home view on the web is working.

Route::get('/', function () {
    return view('welcome');
});

Route::get('/test', function () {
    return view('welcome');
});

I've tried to add this second test route and I do get 404 on the web for it.

Do you have any idea why it is not working and how can I fix it?

0 likes
2 replies
automica's avatar

are you sure you've set the method to POST for your api/refund-link route?

also, you dont need to include __invoke name in your route, format as such:

Route::post('retrieve-link', HistoricalLinksController::class);

any issues with routes can be checked by running php artisan route:list

mcload's avatar

@automica Yes, it's POST. It was working before. None of the routes are working now. I've checked route:list and all of my routes are listed there.

php artisan route:list

GET|HEAD / ........................................................................................................................................................................ POST _ignition/execute-solution ................................................................. ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController GET|HEAD _ignition/health-check ............................................................................. ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController POST _ignition/update-config .......................................................................... ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController POST api/cancel-link ............................................................................................................................ CancelLinkController@__invoke POST api/merchant-refunds/confirm ............................................................................................................ ConfirmRefundController@__invoke POST api/refund-link ............................................................................................................................ RefundLinkController@__invoke POST api/request-link .......................................................................................................................... RequestLinkController@__invoke POST api/retrieve-link ..................................................................................................................... HistoricalLinksController@__invoke POST api/statusUpdates ........................................................................................................................ StatusUpdateController@__invoke GET|HEAD api/user ................................................................................................................................................................. GET|HEAD sanctum/csrf-cookie .................................................................................... sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show GET|HEAD test .....................................................................................................................................................................

                                                                                                                                                                Showing [13] routes

Please or to participate in this conversation.