Laravel on Termux shows 419 Page Expired even with [at]csrf sintax

20 Views Asked by At

I run a Laravel 10 that contains a simple form and I want to know every request value when the form is submitted. The project works well on Windows 10 and Ubuntu, but show error 419 Page Expired when run on Termux 0.118.0 even with @csrf sintax in the form. Any solution, please? Thank you

routes/web.php

Route::get('/media/formulir',[MediaController::class,'formulir']);
Route::post('/media/hasil',[MediaController::class,'hasil']);

app/Http/Controllers/MediaController.php

namespace App\Http\Controllers;

use App\Models\Media;
use Illuminate\Http\Request;

class MediaController extends Controller
{
   
    public function formulir()
    {
        return view('media.formulir');
    }


    public function hasil(Request $request)
    {
        print_r($request['mytext']);
    }

}

resource/views/media/formulir.blade.php

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>The Title</title>
</head>

<body>

    <form method="post" action="/media/hasil">
        @csrf
        <div class="mb-3">
            <label for="mytext" class="form-label">My Text</label>
            <input type="text" class="form-control" name="mytext">
        </div>
        <div class="mb-3">
            <label for="mypassword" class="form-label">My Password</label>
            <input type="password" class="form-control" name="mypassword">
        </div>
        <button type="submit" class="btn btn-primary">Submit</button>
    </form>

</body>
</html>

.env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:xpI4cGKiMciT3YEdBwXOYo1JWraehpbkOckWH/YVCDs=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_APP_NAME="${APP_NAME}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
0

There are 0 best solutions below