Generate Valet-compatible TLS certs for Vite HTTPS auto-detection#31
Merged
munezaclovis merged 2 commits intomainfrom Mar 9, 2026
Merged
Generate Valet-compatible TLS certs for Vite HTTPS auto-detection#31munezaclovis merged 2 commits intomainfrom
munezaclovis merged 2 commits intomainfrom
Conversation
laravel-vite-plugin auto-detects TLS certificates at ~/.config/valet/ to configure the Vite dev server with HTTPS, eliminating mixed content errors when the site is served over HTTPS. pv now mimics this structure: - pv link: generates a per-site TLS cert signed by Caddy's local CA and writes ~/.config/valet/config.json with the TLD - pv unlink: removes the site's cert files - pv setup: writes the Valet config.json when TLD is configured - pv uninstall: cleans up ~/.config/valet/ This means `npm run dev` just works with zero configuration — the Vite plugin detects the certs, serves HTTPS on the .test domain, and the hot file URL uses HTTPS so @Vite generates correct script tags.
- Propagate UserHomeDir errors instead of silently producing relative paths - Remove only certs for pv-linked projects during uninstall, not all of ~/.config/valet - Merge with existing config.json to preserve real Valet settings - Clean up orphaned cert file when key write fails - Return errors from RemoveSiteTLS instead of silently swallowing them - Move CA key path to config.CAKeyPath() to avoid duplication - Wrap parse errors in parsePrivateKey for better diagnostics - Short-circuit cert generation in link when config setup fails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pv linknow generates per-site TLS certificates signed by Caddy's local CA and places them at~/.config/valet/Certificates/wherelaravel-vite-pluginauto-detects themnpm run devjust works — zero configuration neededHow it works
laravel-vite-pluginhas built-in detection for Valet/Herd TLS certificates. It checks~/.config/valet/for:config.jsonwith the TLD (e.g.,{"tld": "test"})Certificates/{hostname}.keyand.crtWhen found, Vite's dev server automatically serves HTTPS on the
.testdomain, and the hot file URL uses HTTPS — so@vitegenerates correct<script>tags with no mixed content.pv now populates this structure:
pv link: generates cert + writesconfig.jsonpv unlink: removes the site's cert filespv setup: writesconfig.jsonwhen TLD is configuredpv uninstall: cleans up~/.config/valet/Test plan
pv link myapp→ verify~/.config/valet/Certificates/myapp.test.{crt,key}existcd myapp && npm run dev→ verify Vite console shows "Using Valet certificate to secure Vite"https://myapp.test→ verify no mixed content errors, HMR workspv unlink myapp→ verify cert files removed