r/PHPhelp • u/lynob • Dec 06 '24
Solved Laravel + Vuejs: How to use HTTPS during development?
I'm on Winows 11. I'm Xampp (it uses APACHE and PHP). Laravel version 8.83.29 and for the frontend I'm using vuejs 2.6.12.
I'm not looking to install new software or change xampp, this is the only Laravel application I maintain, I have 15 other projects working fine under xampp. I'm not looking to upgrade laravel or vuejs, because this is an internal tool used at work, I don't want to spend more than 2h on this. If what I'm asking for is easy to setup then great if not I'll continue working as I'm currently working.
On production the application runs under HTTPS, I don't know how the original dev made it, he uses lots of symlinks and whatnot, he has a 100 lines bash script just to deploy it.
On my PC however, I can't run it under HTTPS because the requests aren't routed correctly by apache or something.
So I'm forced to run
mix watch // to run vuejs
php artisan serve --host=local.dev --port=80 // to run artisan3 things are bothering me with this setup
- Artisan doesn't support HTTPS certificates, I get the SSL warning every time
- I have to run 2 separate commands to run the project
- If I want to use PHPMyAdmin, I'll have to start apache which conflicts with artisan for some reason
I already did research and 2 years ago, the answer was that what I'm doing is correct, you can't serve vuejs and laravel under xampp, you have to use artisan, but we're in 2025 and this development workflow is unacceptable. I feel there must be something I'm missing
5
u/lynob Dec 06 '24 edited Dec 06 '24
I was able to solve the problem, for SSL, I used mkcert in an admin powershell then restart chrome
I defined the domain I want to use in windows hosts file
I used this apache VHOST for xampp
and in the .env file I have this
And now I just run
3
u/punkpang Dec 06 '24
Create a self-signed certificate. Google how to do it, easy command
In your xampp, there's a vhost configuration for your local domain - google how to make it use port 443 and the self-signed cert you used.
There's no such thing, millions of people used xampp with laravel - you need to fix this bit and make it route correctly. Post your vhost config for people to look at.
Once you added the self signed cert and sorted routing, you can use https. Since cert is self signed, you'll get a warning. Type "thisisunsafe" without quotes in the blank screen for browser to accept it.
If you don't want warnings because of self-signed certs, you can use this tool to create local cert authority: https://github.com/FiloSottile/mkcert
3
u/Lumethys Dec 06 '24
What's wrong with Http on local anyway? Why spend time doing something insignificant like this
1
u/MateusAzevedo Dec 06 '24
Then that's what you need to fix. Laravel does work with Apache, you don't need to use
atisan serve.Do you have a VHost specific for this project? Do you have mod rewrite enabled in Apache? Do you have rewrite rules either in
.htaccessor the VHost? Remember that Laravel uses the front controller pattern, it requires that all requires are routed throughindex.php, and that's done with a rewrite rule.0
u/[deleted] Dec 06 '24
[deleted] — view deleted comment