How to register a route in laravel for SPA admin panel - laravel

I am writing a SPA administrative panel site for example (http: // localhost) there you go there a form for entering a login and password, routes laravel handled it and the routes themselves were vue-route
Route::get('/{any}', 'AdminPanelController#index')->where('any', '.*');
Everything works fine, but then I decided to move it to a folder (http: // localhost / admin) and for some reason it does not work
Route::get('/admin/{any}', 'AdminPanelController#index')->where('any', '.*');

If you moved Your whole laravel application, than you'll probably have to adjust your server settings (DocumentRoot). If you moved only your AdminPanelController than I would check if the namespaces are correct. What kind of error are you getting?

Related

How can I define authentication related routes in laravel8?

I followed tutorials and using the below commands I installed all the files needed for register user, login, etc:
composer require laravel/ui
php artisan ui vue --auth
now I have Auth directory in my controllers list and also new forms for register users, login, home and etc are automatically created, I added a link on my page to enter me to registration form, but when I add user, after I hit the register button it says home not found and shows me 404 error which is about route, where I have added Auth::routes(); already to my web blade page. I checked the database, the user is successfully added to the table.
You must add redirectTo property to your auth controller. It's default to /home and you're getting 404 cause you don't have this route.

Not showing modal cookie policy on certain routes

I am using [statikbe/laravel-cookie-consent] package for cookie policy in my Laravel project and I don't want the modal to be shown on certain pages, so I must add the route to ignored_paths array in the config file. For a route as 'admin/users' every thing is fine but for a route as 'admin/user/{id}' it doesn't work. How can I fix it or how can say all the routes which start with '/admin' don't show the cookie policy?

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!

Building on Laravel API backend and Vuejs frontend

I would require a little help here if this method will work out well.
Firstly, I have a backend API server created using Laravel and Laravel Passport. Secondly, I have also created the frontend with Vuejs within the same project. As such, I will be required to use both the api.php and web.php routes. I am also redirecting these routes using vue-router.
Backend
Inside the web.php routes, I have used two different routes because I want to display generic contents on my landing site and the other as an authentication required dashboard.
Example:
web.php
As above, this is to capture the routes which are 404 Not Found that are directly manipulated in the address bar to redirect correctly to their respective pages. I also ended up having two different blade templates named as dashboard.blade.php and home.blade.php respectively. Is this an okay practice for a Laravel-Vuejs project? Or are there ways that you would like to recommend?
dashboard.blade.php
home.blade.php
Login related problem with login page using the layout of the landing page into another layout of the dashboard page
The problem that I am faced with when doing an API login with the password grant is that the login page does not redirect to the dashboard page properly. The URL route does change but the page is rendered as blank.
The login using axios here:
I have managed to fix the problem.
In web.php, since we have
Route::get('/dashboard/{any?}', function () {
return view('dashboard');
})->where('any', '^(?!.*api).*$[\/\w\.-]*');
Inside of my Login.vue redirect handler, I use location.href = '/dashboard' instead of this.$router.push('dashboard').

Routing problems with Laravel 5 on BlueHost Shared Server

I am in the Beta stage of a Laravel 5.0 project using BlueHost as the server. I have not finalised the domain so I am using a temporary address as follows:
IP Address/username
In a normal Laravel project the root URL is the domain name of the website and routing starts from there. However, in this environment, I have to adjust the route.php file. For instance, instead of the familiar
Route::get('/', 'WelcomeController#index');
I've had to do this:
Route::get('/username/', 'WelcomeController#index');
With the usual adjustment in the .htaccess to re-route everything to the public Laravel folder, I can use the temporary address and access the welcome page. However, when I start adding security with the Auth controller, the re-directs don't work. When accessing a secure URL, you are re-directed to IP Address/auth/login instead of IP Address/username/auth/login. In the .htaccess file in the public folder I've added:
RewriteBase /username/
with both slashes, but that doesn't help. Does anyone know how to set up a Laravel project with a secure area, secured by the Auth controller which has a URL that includes a second segment?

Resources