The Route Prefix Trap: Why Your Laravel API Returns 404
A 404 error in a Laravel API usually screams one thing immediately: the router doesn't know how to handle the incoming request. While this is often caused by typos or missing files, it frequently stems from a misunderstanding of how Route::group prefixes interact with nested resource definitions.
In the scenario provided, you are targeting the URL localhost:8888/{projectname}/api/v1/meeting. The output of php artisan route:list confirms that Laravel has registered routes for api/v1/meeting and api/v1/meeting/registration. However, there is a critical mismatch between your expected URL structure and the actual routing logic defined in routes/api.php.
The Missing Base Prefix
The root cause lies in the first line of your route definition:
Route::group(['prefix' => 'v1'], function() { ... });
This group defines a prefix of v1. Inside this group, you define resources like 'meeting' and 'meeting/registration'. When Laravel resolves a request for api/v1/meeting, it correctly matches the meeting resource. However, if your application is served under a subdirectory (such as /api) or if you are appending additional path segments manually in Postman without accounting for the global base path, the router fails to find a match.
More importantly, looking at your Route::resource calls, they are strictly defined relative to the v1 prefix. If your intended endpoint is /{projectname}/api/v1/meeting, and your application root is /api, you have a disconnect. The route list shows GET|HEAD | /api/v1/meeting. If you request /{projectname}/api/v1/meeting where {projectname} resolves to something other than api, or if your server configuration (like .env or public/index.php) expects a different root, the 404 occurs because the incoming URI does not strictly match the registered pattern.
Nested Resources and Path Collisions
The second major issue in your code is the definition of nested resources. You have:
Route::resource('meeting/registration', 'RegistrationController', [
'only' => ['store', 'destroy']
]);
In Laravel, resource routes generate URIs based on the name of the resource. Defining a resource as 'meeting/registration' creates a nested route structure where registration is treated as a child collection of meeting. The generated route for storing a registration would be POST /api/v1/meeting/registration, not POST /api/v1/meeting/registration.
However, if your intention is to have /api/v1/meeting/registration act as a distinct endpoint unrelated to the meeting resource's nested structure, this definition is ambiguous. The router attempts to match meeting/registration against the meeting resource's nested routes first. If that fails, it looks for the explicit 'meeting/registration' group prefix.
If you request POST /api/v1/meeting/registration, Laravel sees the meeting resource exists. It then checks if registration is a valid action on that resource (which it isn't, unless explicitly nested). Since you only included store and destroy in the only array for the nested group, the router might attempt to match it against the parent resource's dynamic segments, leading to confusion.
To fix this, if meeting/registration is a separate logical entity, consider flattening the structure or ensuring the prefix applies correctly:
Route::resource('registration', 'RegistrationController', [
'only' => ['store', 'destroy']
]);
This registers registration at the root of the v1 group. If you specifically need it nested under meetings, ensure your requests target POST /api/v1/meeting/registration/{registration} (for destroy) or POST /api/v1/meeting/registration (for store). The current configuration implies that registration is a child resource of meeting, which means the URI for store should technically be POST /api/v1/meeting/registration.
Resource Routes and HTTP Methods
Another subtle pitfall involves how resource routes handle specific HTTP methods. Your MeetingController defines index, store, show, etc. The route list confirms that GET api/v1/meeting maps to meeting.index. If you are sending a POST request to /api/v1/meeting expecting a different behavior, the router correctly directs it to store.
The 404 error persists if the URI path does not match exactly. For instance, trailing slashes can sometimes cause issues depending on your server configuration (APP_URL or Nginx/Apache settings). If your app is defined at /api/v1/meeting, requesting /api/v1/meeting/ might trigger a redirect loop or a 404 if the index action doesn't handle it gracefully.
Debugging Strategy
To resolve this, verify the exact path registered by running php artisan route:list --path=api/v1. Compare the output URI column strictly against what you are typing into Postman. Ensure that the {projectname} placeholder in your URL actually resolves to the base path configured in your environment (e.g., /api), not an additional segment.
If you are developing locally, ensure APP_URL is set correctly in your .env file to match the base path of your application. Misalignment between the web root and the router prefix is the most common cause of these specific 404 errors when resource routes are involved.