php - 将 Laravel Nova 移至子域
问题描述
我想将 Laravel Nova 移动到nova.mydomain.com
而不是mydomain.de/nova
. 我已经搜索了 GitHub 和 Stackoverflow,但是,这些解决方案对我不起作用。目前我正在尝试这个。
它也有效。Nova 现在可在nova.mydomain.de
. 然而,现在我面临着另外三个问题。
当我尝试访问主域时,
mydomain.de
我还看到了 Laravel Nova 仪表板。它甚至没有重定向我,它只是向我展示了主域上的 Laravel Nova 仪表板!当我在 Laravel Nova 仪表板上单击我的资源上的链接时,它会自动将一个附加
nova.
到所有链接...包含来自主域的所有路由的完整站点也可以在
nova.
. 例如mydomain.com/post/myFirstPost
也可以在nova.mydomain.com/post/myFirstPost
我在 Mac 上运行Laravel Valet
和Laravel 8
. 我nova
在我的文件夹中创建了一个目录,Sites
其中也包含该mydomain
项目。该nova
文件夹只是一个指向mydomain
项目的符号链接。
我怎样才能解决我的问题......不幸的是,网上没有很多讨论和解决方案。
我的 nova.php 配置文件。
<?php
use Laravel\Nova\Actions\ActionResource;
use Laravel\Nova\Http\Middleware\Authenticate;
use Laravel\Nova\Http\Middleware\Authorize;
use Laravel\Nova\Http\Middleware\BootTools;
use Laravel\Nova\Http\Middleware\DispatchServingNovaEvent;
return [
/*
|--------------------------------------------------------------------------
| Nova App Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to display the name of the application within the UI
| or in other locations. Of course, you're free to change the value.
|
*/
'name' => env('NOVA_APP_NAME', env('APP_NAME')),
/*
|--------------------------------------------------------------------------
| Nova App URL
|--------------------------------------------------------------------------
|
| This URL is where users will be directed when clicking the application
| name in the Nova navigation bar. You are free to change this URL to
| any location you wish depending on the needs of your application.
|
*/
'url' => 'nova.' . env('APP_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Nova Path
|--------------------------------------------------------------------------
|
| This is the URI path where Nova will be accessible from. Feel free to
| change this path to anything you like. Note that this URI will not
| affect Nova's internal API routes which aren't exposed to users.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Nova Authentication Guard
|--------------------------------------------------------------------------
|
| This configuration option defines the authentication guard that will
| be used to protect your Nova routes. This option should match one
| of the authentication guards defined in the "auth" config file.
|
*/
'guard' => env('NOVA_GUARD', null),
/*
|--------------------------------------------------------------------------
| Nova Password Reset Broker
|--------------------------------------------------------------------------
|
| This configuration option defines the password broker that will be
| used when passwords are reset. This option should mirror one of
| the password reset options defined in the "auth" config file.
|
*/
'passwords' => env('NOVA_PASSWORDS', null),
/*
|--------------------------------------------------------------------------
| Nova Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Nova route, giving you the
| chance to add your own middleware to this stack or override any of
| the existing middleware. Or, you can just stick with this stack.
|
*/
'middleware' => [
'web',
Authenticate::class,
DispatchServingNovaEvent::class,
BootTools::class,
Authorize::class,
\Vyuldashev\NovaPermission\ForgetCachedPermissions::class,
],
/*
|--------------------------------------------------------------------------
| Nova Pagination Type
|--------------------------------------------------------------------------
|
| This option defines the visual style used in Nova's resource pagination.
| You may choose between 3 types: "simple", "load-more" and "links".
| Feel free to set this option to the visual style you like.
|
*/
'pagination' => 'simple',
/*
|--------------------------------------------------------------------------
| Nova Action Resource Class
|--------------------------------------------------------------------------
|
| This configuration option allows you to specify a custom resource class
| to use instead of the one that ships with Nova. You may use this to
| define any extra form fields or other custom behavior you need.
|
*/
'actions' => [
'resource' => ActionResource::class,
],
];
亲切的问候
解决方案
将您的子域根目录设置为主域根目录。这通常必须在您的网络服务器中完成,例如 apache、nginx
设置
domain
到config/nova.php
您的子域。不要忘记
php artisan optimize:clear