AungMyoOo
AungMyoOo

Reputation: 41

Laravel response also contain request payload

when I make request for forget user password api

POST /api/forget-password

Route::post('forget-password', [UserApiController::class, 'forgetPassword']);

Sample Request

{
  "email": "[email protected]"
}

Expected response

{ "message": "success"}

Actual response what i getting now is

{"email": "[email protected]"}{"message": "success"}

Controller

public function forgetPassword(Request $request)
{
    $user = User::firstWhere('email', $request->email);

    if ($user) {
        $auto_pwd = Str::random(8);

        $hashed_random_password = Hash::make($auto_pwd);
        $user->update([
            'password' => $hashed_random_password,
        ]);

        $this->sendUserCreationEmail($user, $auto_pwd);

        return $this->respondCreateMessageOnly('success');
    } else {
        return $this->respondErrorToken('Enter Correct Email');
    }
}


public function respondCreateMessageOnly($message)
{
    return response()->json([
        // 'code' => Response::HTTP_OK,
        'message' => $message,
    ], 200);
}

here is the controller of that route

Laravel version - Laravel Framework 8.8.0

Upvotes: 0

Views: 727

Answers (2)

imcagri
imcagri

Reputation: 1

That was fixed my problem. auto_prepend_file value changing by itself, so post values sometimes appear on the page #16671 https://github.com/php/php-src/issues/16671

Upvotes: 0

Badman37
Badman37

Reputation: 69

I got the same problem. it's not come from Laravel. The problem has come from docker php-fpm

so I add it to my docker file then working well. my case use: php:8.2-fpm-alpine

RUN sed -i 's/^listen = .*/listen = 127.0.0.1:9000/' /usr/local/etc/php-fpm.d/www.conf

u can refer to it. https://bugs.php.net/bug.php?id=80385

Upvotes: 1

Related Questions