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.
all folders have 777 permissions and i have as well clear all caches so many times
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire