jeudi 22 août 2019

Laravel API Routes using web middleware are not found

I'm trying to setup a simple web api to update some information on my database.

When trying to go to 127.0.0.1/api/login for example it gives a 404 not found.

This is for a new project using Laravel Installer 2.1.0. I've tried setting the middleware to 'web' in the RouteServiceProvider.php

This is my routes\api.php:

Route::get('/login', function (Request $request) {
    return "login";
});

Route::get('/register', function (Request $request) {
    return "register";
});

When trying to go to localhost/api/login it gives a 404 instead of "login" When I do php artisan route:list I get:

+--------+----------+--------------+-------+---------------------------------------------------+------------+
| Domain | Method   | URI          | Name  | Action                                            | Middleware |
+--------+----------+--------------+-------+---------------------------------------------------+------------+
|        | GET|HEAD | /            |       | App\Http\Controllers\PagesController@Index        | web,auth   |
|        | GET|HEAD | account      |       | App\Http\Controllers\PagesController@Account      | web,auth   |
|        | GET|HEAD | api/command  |       | Closure                                           | web        |
|        | GET|HEAD | api/login    |       | Closure                                           | web        |
|        | GET|HEAD | api/register |       | Closure                                           | web        |
|        | GET|HEAD | builder      |       | App\Http\Controllers\PagesController@Builder      | web,auth   |
|        | GET|HEAD | login        | login | App\Http\Controllers\PagesController@Login        | web        |
|        | GET|HEAD | logout       |       | App\Http\Controllers\LoginController@Logout       | web        |
|        | POST     | signin       |       | App\Http\Controllers\LoginController@Authenticate | web        |
|        | GET|HEAD | signin       |       | Closure                                           | web        |
+--------+----------+--------------+-------+---------------------------------------------------+------------+

Edit: I use laravel on Windows and start it by starting my XAMPP webserver




Aucun commentaire:

Enregistrer un commentaire