I have set up api.php as follows
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
/*
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
*/
Route::get('trip', 'TripController@getTrip');
I commented out middleware though I tried with it on first. Just to rule out that it is not affecting somehow.
in my TripController I have:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Trips;
class TripController extends Controller
{
public function getTrip() {
$jeekim = "JEEKIM";
dd($jeekim);
return response()->json(Trips::get(), 200);
}
}
I have my database set up and a few data in it for testing. As I understand now, going to browser with xxx.xxx.xxx.xxx/api/trip should open this ? But instead I get 404: The requested URL was not found on this server. I added variable in controller and dd just to see if I reach controller function but no.
I made sure i have a2enmod rewrite enabled. I use ocean droplet cloud server, not on localhost. I have a testing route in web.php and it works, I can return a view. But this api route I cant get to work.