【问题标题】:How can I to edit or remove the URLs of the authentication by default in Laravel using Inertia JS?如何使用 Inertia JS 在 Laravel 中默认编辑或删除身份验证的 URL?
【发布时间】:2021-08-26 21:21:40
【问题描述】:

我正在使用 Laravel 8 和 Inertia JS 和 VueJS 开始一个新项目。我正在使用 Inertia 生成的身份验证路由和视图,但在我的应用程序中我不需要 /register url,因此我需要将其删除以避免其他人输入 URL。

我怎样才能删除它?或者管理 Inertia 生成的 url 的地方在哪里?或者例如,如果我不想删除网址,但我想将其重命名为/signup,我该怎么做?

我一直在惯性文档中寻找信息,但没有找到任何信息。

这是我的 web.php 路由文件,这些路由不在这里

<?php

use App\Http\Controllers\Experimental\RandomController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'canLogin' => Route::has('login'),
        'canRegister' => Route::has('register'),
        'laravelVersion' => Application::VERSION,
        'phpVersion' => PHP_VERSION,
    ]);
});

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return Inertia::render('Dashboard');
})->name('dashboard');

更新 1: 我正在使用 Laravel Jetstream

【问题讨论】:

  • 你在使用 Laravel Jetstream 吗?
  • 是的,很抱歉。我忘了把它放在问题中。已更新。

标签: php laravel vue.js laravel-8 inertiajs


【解决方案1】:

他们似乎没有记录如何做到这一点,但从 Fortify 配置文件中看起来是可行的。

打开config/fortify.php 并从数组中注释或删除Features::registration(),

use Laravel\Fortify\Features;

'features' => [
    // Features::registration(),
    // ...
],

【讨论】:

    【解决方案2】:

    检查路由下的auth.php,你应该在那里找到所有的auth路由。因此,您可以重命名注册 url 以注册并创建新控制器或重命名注册用户控制器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      相关资源
      最近更新 更多