Skip to content

[0.6.x] Add config option to utilise Valet TLS certificates #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 15, 2022

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Aug 25, 2022

This PR introduces a new valetTls configuration option to allow developers to use Valet generated certificates on their Mac. This is useful as Vite 3 no longer generates a self signed certificate. Valet also puts certificates into the system keychain, so if you are using Chromium or Safari the experience is seamless.

Unfortunately Firefox does not seem to read from the system keychain, so you may still need to additionally accept the Valet certificate for the Vite server, as we currently have to.

When setting the configuration option to true, the plugin will automatically detect the host by checking the current directory name and appending the configured Valet TLD:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            valetTls: true,
        }),
    ],
});

If you have linked you site via a different host, that is if you are in the my-app directory and ran:

valet link my-host
valet secure my-host

so that you can view "my-app" by visiting https://my-host.test, then you should specify the host along with the TLD in the valetTls option:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            valetTls: 'my-host.test',
        }),
    ],
});

User config will always take precedence over the underlying generated Valet config.

Documentation PR: laravel/docs#8164

@timacdonald timacdonald force-pushed the valet-tls branch 6 times, most recently from 4fb4296 to 8e0eb21 Compare August 26, 2022 02:32
@timacdonald timacdonald requested a review from jessarcher August 26, 2022 02:54
@timacdonald timacdonald changed the title [0.5.x] Detect valet tls [0.5.x] Config to utilise Valet TLS certificates Aug 26, 2022
@timacdonald timacdonald changed the title [0.5.x] Config to utilise Valet TLS certificates [0.5.x] Add config option to utilise Valet TLS certificates Aug 26, 2022
@timacdonald timacdonald marked this pull request as ready for review August 26, 2022 04:09
@timacdonald timacdonald changed the title [0.5.x] Add config option to utilise Valet TLS certificates [0.6.x] Add config option to utilise Valet TLS certificates Aug 27, 2022
@jessarcher
Copy link
Member

Looks good!

I note that Vite has introduced a separate plugin for SSL (https://github.com/vitejs/vite-plugin-basic-ssl) but I like this option for Valet users so they don't need to install anything additional.

I wonder whether we should document https://github.com/vitejs/vite-plugin-basic-ssl for non-Valet users?

@timacdonald
Copy link
Member Author

Interesting! I've added that to the docs, but kept it as the last line of defense as Vite is recommending people generate their own - but still good to include.

Screen Shot 2022-08-29 at 1 50 36 pm

Copy link
Member

@jessarcher jessarcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works a treat! 🚢

@driesvints
Copy link
Member

@jessarcher @timacdonald think @taylorotwell is not going to review this, right? Can you merge this yourself?

@taylorotwell taylorotwell merged commit ee891f7 into main Sep 15, 2022
@taylorotwell taylorotwell deleted the valet-tls branch September 15, 2022 13:25
greatislander added a commit to accessibility-exchange/platform that referenced this pull request Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants