1

I have created APIs with sanctum authentication and moved the laravel application into the production server after uploading it to the server, the production API route are not working

  • I have check my .htaccess files in my project structure
 <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.html.var
</IfModule>

Also Change in RouteServiceProvider

public function boot()
   {
    $this->configureRateLimiting();

    $this->routes(function () {
        Route::middleware('api')
            ->prefix('api')
            ->group(base_path('routes/api.php'));

        Route::middleware('web')
            ->group(base_path('routes/web.php'));
    });
   }
  • api.php file
Route::get('test',function(){
    return 'Hello';
});
  • url: http://{ipAddress}/api/test
2
  • What kind of error message did you get? Is it a 404 error? Commented Mar 27, 2023 at 6:57
  • Turn on errors, and what kind of error message did you get? Commented Mar 27, 2023 at 6:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.