Using Laravel Vite with MAMP
As seen in other posts, I use MAMP quite a bit for my web development environment. I know I can run docker, or any of the other platforms out there but they use more memory and resources that I'd prefer to devote to my dev tools.
I started a new Laravel project and wanted to use MAMP but Vite was throwing errors due to the SSL not matching out of the box.
When adding
to my blade file, I'd get errors including:
I found articles saying to add --https or --host to my package json command but then I got this error:
Load MAMP Pro, add your host and generate your SSL certificates. For this example, we'll use set the host name to my-app.test, and assume you're storing the SSL keys in the default location.
Open vite.config.js and add the following 2 lines:
Then add this to defineConfig section:
You should now be able to run npm run dev and have no issues.
Sample full vite.config.js file for easy reference: