samedi 22 février 2020

My Laravel 5.5 app not working on remote server namecheap VPS after deployment but working fine on local server with WAMP

Everything about this app is working fine on my local sever, but refused to work remotely. if i visit the app www.mysite.com. It always shows internal server error. Though i don't have any route in web.php but i expected to redirect back to 404 not found page but not doing that but it does on localhost.

The other main problem is , i have many routes in api.php, if i send data to any of the routes, they accept data and might even save them in database where it is necessary but it will never return the json Response that i have defined after every successful operation. The response i always get is 500 internal server error even if the operation was successful. I have been on this issue for over two weeks now.

I am using PHP 7.2 on the server

Here is my .htaccess file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    RewriteEngine On
    RewriteBase /
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

api.php

<?php

Route::group(['prefix' => 'user', 'namespace' => 'User'], function () {

    Route::post('/login', 'UserAuthController@userLogin');
    Route::post('/signup', 'UserAuthController@userSignup');

});

UserController.php

public function userSignup(Request $request)
    {
        $rules = [
            'name' => 'required|string|max:200',
            'password' => 'required|between:8,100|confirmed',
            'phone' => 'unique:users|required|digits:11|numeric',
            'email' => 'unique:users|required|email',

        ];
        $validator = Validator::make($request->all(), $rules);
        $code = mt_rand(100000, 900000);
        $hCode = FacadesHash::make($code);
        if ($validator->passes()) {
            $user = User::create([
                'name' => $request['name'],
                'email' => $request['email'],
                'phone' => $request['phone'],
                'otp' => $hCode,
                'password' => FacadesHash::make($request['password']),
            ]);

            $data = [
                'name' => $request['name'], 'subject' => 'Email Confirmation',
                'view' => 'mails.emailconfirm', 'code' => $code
            ];


            return response()->json(['success' => true, 'status' => 200, 'message' => 'Your account has been created successfully and an OTP code has been sent to your email'], 200);
        } else {

            return response()->json(['success' => false, 'status' => 200, 'message' => $validator->errors()->first()], 200);
        }
    }

the signup route for example, is working fine but will never return the Json response i specified, it will rather return 500 internal server error even if everything went well.

No error is being logged in my storage/log if everything went well and i dont get the response. But i do see error there if the operation was not successful.



via Chebli Mohamed

1 commentaire:

  1. Did you know there's a 12 word phrase you can speak to your man... that will induce intense feelings of love and instinctual attraction to you buried inside his chest?

    That's because hidden in these 12 words is a "secret signal" that triggers a man's impulse to love, cherish and guard you with all his heart...

    12 Words That Trigger A Man's Desire Response

    This impulse is so hardwired into a man's genetics that it will drive him to try better than before to to be the best lover he can be.

    As a matter of fact, triggering this dominant impulse is absolutely binding to getting the best ever relationship with your man that the moment you send your man one of the "Secret Signals"...

    ...You will soon find him open his heart and soul to you in such a way he haven't expressed before and he will distinguish you as the only woman in the universe who has ever truly appealed to him.

    RépondreSupprimer