I can not create new Routes in Laravel project - laravel

I was developing a Full-Stack Laravel project using livewire and tailwind CSS in the front, everything was working just fine, I even did 5 commits on GitHub on this project. The problem is I came back to continue developing the project, and when I create new routes, Laravel returns 404 PAGE NOT FOUND, I even tried to test a very simple route, and it did not work too(404 page not found)
Route::get('/test', function () {
return 'hi';
});
Any solution to this weird problem?

Might be a chaching problem.
Try clear your cache by running
php artisan cache:clear
php artisan clear
You can also check all registered routes by running
php artisan route:list.
If thats not working it could also be a problem with the browsers internal cache. Had something like this before with Firefox.
Try using curl to access the endpoint
curl http://localhost:8080/test

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 sanctum problem when deployed to Heroku

Hello guys I've been trying to build a full-stack web app, and everything was working fine on my localhost using postman. But after uploading to Heroku, it would seem I have a problem with sanctum. It keeps throwing this error:
Things I've tried:
Run composer update
php artisan cache:clear
Trying to add sanctum with composer require laravel/sanctum.
Following sanctums installation guide with all steps on the Laravel home page
And this is inside my api.php where I guess the initial error starts.
Route::middleware('auth:sanctum')->group(function () {
// User Routes
Route::get('profile', [UserController::class, 'profile']);
Route::get('logout', [UserController::class, 'logout']);
});
I've been at it the whole weekend but I can't seem to crack this one, Also apologies in advance I have classes soon, so responding back will be slow.

I am seeing old laravel site even after updating files

I have a website that uses vuejs as frontend and Laravel API in backend. Recently I updated my Laravel site it was working absolutely fine in my localhost. But the problem is when I upload my Laravel files to my hostinger.com hosting account it's not updating. It's displaying me old site but my database got updated and I was able to errors of the new site.
I tried these none of them seems to be working,
Cleared browser history and cache
Tried reuploading site again
I ran following commands
php artisan config:cache
php artisan route:cache
php artisan view:cache
npm run prod
Tried to use cmd command ipconfig/flushdns
Still, I was not able to solve the issue.
Have you tried refreshing your website with CTRL+F5 or CTRL+R ?

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' }}

Resources