Got a React app that you want to serve via HTTPS so you can test things like Websockets and CORS issues locally?
Throw this LocalValetDriver.php
into the root of the project and Herd will just serve the static files for you.
Switch on SSL for that site in Herd's settings or command line and you've got a fully working app just like in prod.
No other tools required. No self-signed certs to generate.
You then just need to explicitly visit the file path in your browser.
Let's say you have a project called react-app
. As long as Herd knows about this, you'll be able to access it in your browser at something like http://react-app.test/, without needing to run a Vite or Webpack server.
Assuming it has a public/index.html
file in it, after putting this Valet driver into the root, you'll be able to visit http://react-app.test/index.html and see the page load up.
Now turn on SSL and you can load it via https://react-app.test/index.html
This is a very basic version of one of the default Valet drivers. Because Herd is built around Valet, you can use all of these and more.
putting this file in the site directory didnt work for me, i was running vite as well, so i found this repo, and put the
DistStaticValetDriver
in~/Library/Application\ Support/Herd/config/valet/Drivers
directory and it worked like a charm