【问题标题】:Signed URL for subdomain in Laravel 8Laravel 8 中子域的签名 URL
【发布时间】:2021-10-12 07:53:58
【问题描述】:

我正在尝试生成在 Laravel 8 中签名的 URL,以便应用程序的客户端可以取消事件而无需访问。我正在使用具有两个子域 foo.domain.com 和 bar.domain.com 的多租户。然而,Laravel 只为主域生成签名 URL。有什么方法可以改变 Laravel 的行为来理解和生成子域的签名 URL?

public function generateLink($id, $username, $whatsapp)
{
    return Url::temporarySignedRoute('confirmpage', now()->addMinutes(20), [
        'id' => $id,
        'user' => $username,
        'whatsapp' => $whatsapp
    ]);
}

【问题讨论】:

    标签: php url routes subdomain laravel-8


    【解决方案1】:

    您应该在路由中配置动态域:

    $domain = '{外部}'; Route::domain($domain)->group(function () { Route::name('external.')->group(function () { Route::name('verification.')->group(function () { Route::post('verification/verify/{id}/{hash}', [\App\Controllers\VerificationController::class, 'verify'])->name('verify'); }); }); });

    然后覆盖它:

    $verifyUrl = URL::temporarySignedRoute( 'external.verification.verify', Carbon::now()->addMinutes(config('access.verification.expires', 1440)), [ 'id' => $notifiable->getKey(), 'hash' => sha1($notifiable->getEmailForVerification()), '外部' => parse_url(env('MYAPP_URL'), PHP_URL_HOST), ] );

    【讨论】:

      猜你喜欢
      • 2017-02-08
      • 1970-01-01
      • 2019-06-29
      • 2021-06-22
      • 2019-03-19
      • 2016-07-29
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多