After deploying the Laravel project on CentOS, try to access the http://127.0.0.1:8000/api link and find that the 404 page is automatically redirected, but http://127.0.0.1:8000 the link access is normal, you can also log in to the default account normally.
It should be the latest version, downloaded and deployed in the last week.
PHP:8.1.13(If PHP-8.0.26 is used, an error is reported with an old version)
Node:v18.12.1(If you use v-14.16.1, you will get an error that the version is low)
npm:9.2.0
pm2:5.2.2
yarn:1.22.19
Hi,
Have you set the routes for API? Please check this file. /routes/api.php
Thanks
I've determined that this file exists, it can be edited normally, it just can't be opened in the link
Hi,
In the /routes/api.php file, please try to add this route.
Route::get("/user", function (Request $request) {
return $request->user();
});
It can be accessed normally, thank you. Another thing is whether you can share the /api/login sample code
Hi,
Sorry, we do not have an example for the login API. You can consider checking this guide for the authentication login using the API.
https://laravel.com/docs/9.x/sanctum
Thanks