'forgot password work finely in local, but does not work in heroku

so i have a laravel app that have forgot password through email function. my reset password is work fine in local .the problem is when i host my app into heroku, the status password reset keep returning invalid value. when i use the token, i can use the token in my local app, but does not work in heroku

Here is my controller


namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Validation\ValidationException;
use Illuminate\Validation\Rules\Password as RulesPassword;

class ForgotPasswordController extends Controller
{
    use ResetsPassword;
    
    public function forgot_password(Request $request)
    {
        $request->validate([
            'email' => 'required|email'
        ]);

        $status = Password::sendResetLink(
            $request->only('email')
        );

        if ($status == Password::RESET_LINK_SENT) {
            return [
                'status' => __($status)
            ];
        }

        throw ValidationException::withMessages([
            'email' => [trans($status)]
        ]);
    }
    public function reset_password(Request $request)
    {
        $request->validate([
            'token' => 'required',
            'password' => ['required', 'confirmed'],
            'email' => 'required'
        ]);

        $status = Password::reset(
            $request->only('password', 'password_confirmation', 'token'),
            function() use ($request) {
                $user = User::whereEmail($request->email)->first();
                $user->update([
                    'password' => Hash::make($request->password),
                    'remember_token' => Str::random(60)
                ]);

                event(new PasswordReset($user));
            }
        );

        if ($status == Password::PASSWORD_RESET) {
            return view('reset_success');
        }

        return view('token-reset-expired');
    }

    public function form_reset_password($token)
    {
        return view('form-reset-password', [
            'token' => $token,
        ]);
    }
}

my reset password notification method in user model

public function sendPasswordResetNotification($token)
    {
        $base_url = 'https://MyApp.herokuapp.com';
        $url = $base_url.'/api/form-reset-password/'.$token;
        $this->notify(new ResetPasswordNotification($url));
    } 

and my routes in api.php

Route::post('/forgot-password', [ForgotPasswordController::class, 'forgot_password']);
Route::post('/reset-password', [ForgotPasswordController::class, 'reset_password'])->name('resetpassword');
Route::get('/form-reset-password/{token}', [ForgotPasswordController::class, 'form_reset_password']);



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source