Move Laravel Nova to subdomain

1.3k views Asked by At

I would like to move Laravel Nova to nova.mydomain.com instead of mydomain.de/nova. I have already searched to GitHub and Stackoverflow, however, the solutions don't work for me. Currently I am trying this one out.

It also works. Nova is now available under nova.mydomain.de. However, now I am facing three other problems.

  1. When I try to access to main domain on mydomain.de I also see the Laravel Nova dashboard. It is not even redirecting me, it is just showing me the Laravel Nova dashboard on the main domain!

  2. When I click on a link on my resources on the Laravel Nova dashboard it automatically appends a nova. to all links...

  3. The complete site including all routes from the main domain are also available under nova.. For example mydomain.com/post/myFirstPost is also available under nova.mydomain.com/post/myFirstPost

I am running on Mac with Laravel Valet and Laravel 8. I have created a nova directory in my Sites folder which also contains the mydomain project. The nova folder is just a symlink which points to the mydomain project.

How can I fix my problems... Unfortountly there aren't many discussions, solutions available online.

My nova.php config file.

<?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,
    ],

];

Kind regards

1

There are 1 answers

0
Sadegh PM On
  • Set your subdomain root directory to main domain root directory. This is typicaly must be done in your webserver like apache,nginx

  • Set domain in config/nova.php to your subdomain.

  • dont forget to php artisan optimize:clear