Laravel route with inertia and slash route - laravel

I installed and configured the inertia on my laravel app and wanted to create also an admin along with the already established single page functionality on my app and wanted to group it under /admin
Route::prefix('/admin')->group(function(){
Route::get('/login',[AdminController::class, 'login'])->name('admin.login');
});
the above route is expected to be accessible at "<domain>/admin/login" but not working at all. Any help, suggestions, ideas is greatly appreciated.

use ::prefix('admin')-> without the slash

1) ::prefix('admin') remove slash.
2) run php artisan route:cache and it will work!

Related

How to access laravel api from vuejs frontend?

I have built a laravel api, I have placed the backend inside a laravel folder in the cpanel and the built vuejs frontend inside public_html, now u can see I am using both api.php and web.php, my frontend is working fine when I visit https://www.example.com but what's the url to my api endpoints since when I try something like https://www.example.com/api/somepage it doesn't work it just hits the routes I set using vue router?
Please I need help here I am a beginner, and thanks in advance.
Laravel apis have default middleware to establish security. Make sure you send tokens. In my opinion, test it in postman first.
If you have a 404 error , this link can help you
Sometimes it is possible that there is a problem with the route cache, so it is better to delete the route cache and create it again
php artisan route:clear
php artisan route:cache

Laravel 5.1 - Some pages are not found on production serveur - "Page you are looking for could not be found"

I have a problem with some "routes" in my old Laravel 5.1.46 project.
When I try to access to some routes, like admin/exercices/creer or admin/exercices/1928, I have this: "Sorry, the page you are looking for could not be found.".
I can access to thoses pages when I work on the test or local serveur. But not on the production serveur.
Other routes like admin/missions/creer are working properly.
I tried php artisan route:list to compare the routes on each serveur: it's the same everywhere.
I also tried php artisan route:cache and php artisan route:clear. Nothing changed.
I can remember we changed the routes path (for example: "admin/modules/creer" became "admin/exercices/creer"). I think we did it manually, directly in the routes.php file. But it waas a long time ago and since then, it already worked properly. So I don't think it comes from that, but Idk.
I'm also not good at sysadmin, so maybe it's more about the config of the server than code and laravel... In this case, any idea here does it come from? I have no clue, and I might need help.
Thanks a lot for reading! And let me know if you have even a tiny idea!

New Laravel project, /login is forbidden

There are a couple of questions like this, but none of them worked for me.
I have a new project in Laravel. I created new /register route, works perfectly.
But /login is not working. I'm getting 403 Forbidden error and nginx/1.13.3 beneath. I tried adding new .htaccess file in the root of the project and it didn't work.
I have a project that I created couple of months ago, with the same route /login and it still works perfectly, with no .htaccess fine in root.
I'm using Homestead machine as the server and I have Laravel 5.6.1. project.
And, no matter what I do, the same error is still there. I can remove the route, the controller or the view (just to provoke new, familiar error) but still the same one.
Any ideas what is going on?
First, nginx doesn't need an .htaccess file. It exists for apache users in new Laravel projects.
Second, Laravel has the authentication routes builtin, you shouldn't need to create login and register routes. Run:
php artisan make:auth
to scaffold your auth routes and views. Try removing the /register route you created and run the above command.
Just run
php artisan make:auth
and
php artisan migrate
in a fresh Laravel application.
Then, navigate your browser to
http://your-app.dev/register
or any other URL that is assigned to your application. These two commands will take care of scaffolding your entire authentication system!

Set Laravel Application Urls

Fairly new to Laravel here and I'm struggling to understand how to make Laravel 5.2 aware of where it resides. Here's the issue:
I set up auth using php artisan make:auth, and can now see the lovely landing page, as well as login and register links in the menu. The problem is that these links don't go to the right place. They point to /login and /register in the code respectively, which translates into http://localhost/login or http://localhost/register. But since I'm not on a production site yet and am developing locally, my website resides at http://localhost/projectname/public.
I've gone into config/app.php and tried various values for the URL parameter, but these have no effect.
What can I do to get these links to reflect the full site URL, without manually entering it each time?
you can run the development server in laravel using this command
php artisan serve
Did you try that?
Use laravel url function:
{{ url().'/login' }}

laravel 5.1: redirecting in AuthController doesn't work (using xampp)

I am using laravel 5.1 and I am trying to make it possible for users to log in to my app. I'm doing this in xampp, so my login path looks like this: http://localhost/laravel/public/index.php/auth/login.
However, when I try to log in it redirects me to http://localhost/auth/login and gives a 404 error. It does this too when the login fails. I have tried to set the 'protected $redirectPath' and 'protected $loginPath' in the AuthController to something like localhost/laravel/public/index.php/ to get to the home page, but it doesn't work and still goes to http://localhost/auth/login. I would be very grateful to anyone that could help me out or explain to me how I can make the redirecting work after logging in or failing to log in.
Just fixed my own problem: it turns out that I was posting my login form to /auth/login (I had just copied the example from the laravel docs), so I changed that to /laravel/public/index.php/auth/login and now everything is acting as it should again!
its better to use
php artisan serve
in your project route if you're developing in localhost because you can control your routes more easily and you can get rid of localhost/laravel/public/index.php/ .

Resources