Slim 404 when moved to godaddy from local turnkey vm - php

So, I had a working application on a turnkey VM using slim and I decided to move it all to a hosted server when I started having issues with Slim. I got 404 on my endpoint calls. I then brought up fiddler and did a call directly to the index.php that contains the Slim endpoints. I got 404 on that. I then removed all the Slim code from index.php and called it again. This time I got 200. Adding back in the slim code a line at a time it didn't bring back 404 until I brought back
$app->run();
The test calls from fiddler where all directly to index.php and not to an endpoint within it.
Does anyone know what I need to do here? I have no rewrite rules set up in my htaccess.

Related

Laravel API Get method is working fine, Put,Delete,Post methods are not working on live server and with laragon pretty URL

Laravel API Get method is working fine, Put,Delete,Post methods are not working on live server and with laragon pretty URL.
When i add index.php with the url its work.
(eg:https://www.example.com/index.php/api/create-user)
what is the reason behind it.
The issue is your .htaccess file.
If you correct the .htaccess file it will work without the need to add ...index.php
You can share your .htaccess of use the default one that comes with Laravel.

Laravel Passport Consuming own API with Axios 401 Unauthenticated

i can't seem to consume my own Laravel API with Axios, i have tried almost all solutions i came across
can someone please help me out,
i have properly:
Installed.
Registered passport service provider.
Migrated and generated passport keys.
Added HasApiTokens trait into my user model.
Added Passport::routes() into AuthServiceProvider.php.
Change my config\auth.php.
Added \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class into last place my web middleware group. as per the laravel documentation for consuming own api with javascript.
i have tested it with Axios inside vue components in a web browser normal web login. and through postman: api-login, using the returned token to make api call it works on my development machine. But on my production server(Shared Hosting) it keeps returning "Unauthorized" in web browser using web login and using Axios within vue component, and API call in postman returns "Unauthorized" too after login i get a token with i use in making the Postman call.
i checked the request headers are sent too:
x-csrf-token
x-xsrf-token
and also included in the cookie header
Please, ensure the following things as you are running laravel on shared hosting.
Check your root URL set properly with a public folder or You have moved the files of the public folder into the root.
Most importantly check you have .env file & all the files & folders have the proper permissions.
Also, check all the PHP modules (laravel requirements) that are loaded properly with the proper PHP version.
If above steps are correct, then the problem might be your shared server using fcgi rather than regular PHP module. Hence, HTTP_AUTHORIZATION failing there. You can add following codes into the .htaccess file RewriteEngine On RewriteCond %{HTTP:Authorization} ^(.+)$ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] that should do HTTP_AUTHORIZATION & solve the problem.
I hope these fix your problem.

Elastic Beanstalk Laravel Deployment Returns The requested URL /login was not found on this server

I'm tying to deploy a new version of my application developed with Laravel and using Elastic Beanstalk. Once the application is deployed I get the following message on the browser: The requested URL /login was not found on this server. I tried multiple routes and all return the same. If I type /index.php/login I get to the correct page but then get back to error when the site tries to redirect to /home.
Up to this point, previous versions were all functional. I can even go back and revert to the previous version released and everything goes back to normal. Since this is the case I started analyzing what's different in these two versions. I made some changes in a couple of views, but the login view was not modified. I also added a number of routes went from 13 to 16.
This picture shows a comparison between the old and new web.php files green being the old file:
Has anyone encountered a similar error before? Thanks.
I found that the culprit for this response was an improperly named "/public/.htaccess" file. In my case the file had been renamed to "_htaccess" probably when I transferred the code from one computer to another.

Laravel "return redirect" not working on Heroku

I have a larval application I've recently deployed to a Heroku server and set up SSL for.
I have a couple instances of the following code which is called in various functions that should all redirect to the same spot. All the code in the related functions preceding it executes correctly.
return redirect('/cart');
Locally, this works as intended, but on heroku it returns www.site.com/index.php
Accessing the the url /cart works correctly when not using "redirect".
I've checked the error logs on heroku and they don't show anything particularly helpful, just a request to the route that later returns the redirect.

How to escape subfolder in slim3 framework being routed by slim3

I have a project built with slim 3 and is working as expected (http://localhost/slimapp/). Now what I want to do is in one of the subfolder run an Angular2 application. But as I try to access the subfolder (http://localhost/slimapp/angularapp/) via browser it is redirected to index.php of slim3, which is quite obvious. What I want to achieve is when I visit http://localhost/slimapp/angularapp/ this URL should not be redirected through slim3 .htaccess and it should run an angular application.
So far I tried in .htaccess is add
RewriteRule ^angularapp($|/) - [L,NC]
This results in 404 not found a page for http://localhost/slimapp/angularapp/.
Any help is much appreciated.
Thanks
instead of rewriting it on the .htaccess level, just create a web-route from slim for that particular path, so instead of you accessing it from the browser, you would access Slim App, and it will access the angular app for you.

Categories