-
Notifications
You must be signed in to change notification settings - Fork 155
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
Dev server ping fails with secured Valet site #27
Comments
This is probably not Valet related. I have the same issue serving the local dev site with Lando (Docker). |
This is only an issue with Vite 2.x, the ping works differently in Vite 3.x which will be released in the upcoming days/weeks (see vitejs/vite#6819). I'm not even sure if this is fixable on our side because the ping uses the |
That's good to know 👍🏻 I think the socket connection is also failing initially, which is a bigger problem right? It must have something to do with using HTTPS locally but I'm not sure if the fix would be something in Vite, this plugin, Valet, or somewhere else. |
Yes, you're getting the ping loop because Vite couldn't connect in the first place - I think the Vite plugin should do that automatically, but for now maybe try configuring I'll try that tomorrow, I don't recall what needs to be setup on the top of my head |
Thanks for reporting this, @bakerkretzmar. The I don't have a Mac (and therefore Valet) to reproduce the socket issue, but I'll check it out with @timacdonald's help tomorrow. |
Hey, so I just tried and at least the following import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel([
'resources/css/app.css',
'resources/js/app.js',
]),
],
server: {
https: true,
hmr: {
host: 'localhost',
}
}
}); The @jessarcher I think the I haven't looked into why |
@innocenzi thanks a ton, I'll add that config! It sounds like that wouldn't be super hard to figure out and configure automatically inside this plugin, hopefully that can be added 👍🏻 |
Just pointing out here that this isn't valet specific, it's anything that allows you to have a valid https local dev setup that's not on https://localhost. |
I agree that setting It's also possible to force the Vite client to connect over As for When you browse to your Valet site over It does not accept the Vite certificate. The only way I can see to accept the Vite certificate is to browse to the
I suspect this would work if you browsed to It is possible to configure Vite to use Valet's key and certificate, however, this does not solve the issue because the certificate needs to be accepted separately for each port (i.e. 443 and 3000). This is not a problem in the normal Vite world because they always browse to port 3000. |
You are absolutely correct it's more complicated than it first seems. I was considering whether we could setup vite to proxy through to the laravel site so we could manage it the same way they do in the vite world, but that wouldn't work for subdomain routed apps. I feel like the only suitable 'solution' to this issue is going t o be education on typical debugging steps given the range of setups people may have. |
This is what I'm leaning towards as well. I still think it's worth setting We could also consider adding some output to the console when this is set, with a link to the vite dev server URL so they can easily click it and accept the certificate. It's also worth noting that this issue exists with Mix as well. |
I don't think we should detect this from the
None of these are related in anyway to the APP_URL, so I don't think auto-detecting is a good idea. The APP_URL may be https and the site may not be and vice-versa. |
That's a good point @timacdonald. Also, if no one provides a Until we can think of something more reliable, I think we'll just document adding this to
And then to make sure to visit the following link to accept the certificate: |
This has been added to the docs PR at laravel/docs@168786d Going to close this issue for now. Thanks again for all your help everyone! |
@timacdonald I still think I can confirm we still need to accept the certificate, but we indeed need to do that only once. Laravel Vite auto-detects Valet and Laragon certificates and uses them, which reduces the configuration needed by the user to get I don't think it's bad to have good defaults that would work in a lot of cases, even if not all of them. |
@jessarcher thanks a lot! Glad this is documented now, and I think accepting the additional certificate is a good workaround. I still think it makes sense to use |
I'm not shutting down the idea at all, just sharing a perspective. Will chat to Jess more about it and maybe have a play with the idea a bit more. Thanks for all the discussion folks ❤️ |
I had the same problem, I fixed it by adding the key and certificate as I already did with laravel mix. I created an article to show this working. 👉 https://dev.to/paulocastellano/how-to-make-vite-valet-and-ssl-works-together-5hbb |
While this works, when testing Hopefully there's a cleaner way to make this work with Valet. Seems a bit of extra fluff to start new projects compared to Mix. |
Description:
When serving a local development site, e.g.
valet-vite.test
, using Valet, after the site is secured with HTTPS usingvalet secure
the connection towss://valet-vite.test:3000
fails, and all the pings tohttps://valet-vite.test/__vite_ping
404.The errors look like this (screenshot is Firefox, errors are the same in Chrome).
Steps To Reproduce:
composer create-project laravel/laravel:9.x-dev valet-vite && cd valet-vite
valet link valet-vite && valet secure
@vite('resources/js/app.js')
toresources/views/welcome.blade.php
APP_URL
tohttps://valet-vite.test
npm install && npm run dev
The text was updated successfully, but these errors were encountered: