Search code examples
laravellaravel-nova

Laravel Nova: The login form is in HTTP instead of HTTPS


Context

I've installed Laravel Nova, executed the migrations and created the Nova user by following the docs https://nova.laravel.com/docs/3.0/installation.html#installing-nova . Now I'm trying to login.

Expected behavior

When I send the login form, I'm redirected to the backoffice panel.

Actual behavior

When I send the login form, I'm redirected to a Chrome page "This page is not secured, are you sure you want to send your form data?" (approximately the English translation of the French displayed error :D ).

Clues

The login form is shown at this URL: "https://.../nova/login".

The login form, however, contains this action: "http://.../nova/login" - NB: so it's not HTTPS, but HTTP.

Question

Where could I set a Laravel and/or Nova config option to tell Nova to use https instead of http in the action of the login form Nova shows?


Solution

  • Since Nova doesn't seem to use any environment/configuration option to be able to choose the good HTTP/HTTPS protocol, I've directly written the following, in app/Providers/AppServiceProvider (NB: I don't really know the drawbacks of this solution so I don't recommend you to do it, even if in my case it worked well to fix this bug):

    public function boot()
    {
        \URL::forceScheme('https');
    }