question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dev server ping fails with secured Valet site

See original GitHub issue
  • Laravel Vite Plugin Version: 0.2.3
  • Laravel Version: 9.x-dev 4d46bda
  • Node Version: 16.15.0
  • NPM Version: 8.5.5
  • Chrome Version: 102.0.5005.115
  • Firefox Version: 101.0.1
  • Laravel Valet Version: 3.1.7
  • macOS Version: 12.3.1 (M1)

Description:

When serving a local development site, e.g. valet-vite.test, using Valet, after the site is secured with HTTPS using valet secure the connection to wss://valet-vite.test:3000 fails, and all the pings to https://valet-vite.test/__vite_ping 404.

The errors look like this (screenshot is Firefox, errors are the same in Chrome).

Screen Shot 2022-06-24 at 2 17 21 PM

Steps To Reproduce:

  • composer create-project laravel/laravel:9.x-dev valet-vite && cd valet-vite
  • valet link valet-vite && valet secure
  • add @vite('resources/js/app.js') to resources/views/welcome.blade.php
  • set APP_URL to https://valet-vite.test
  • npm install && npm run dev

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
innocenzicommented, Jun 26, 2022

Hey, so I just tried and at least the following server configuration is needed for https to work and the websocket to connect:

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 host is necessary because otherwise the websocket will try to connect using location.hostname.

@jessarcher I think the hmr host should always be set, and https should be auto-determined depending on APP_URL, like vite-plugin-laravel does.

I haven’t looked into why ws://browser-hostname works and wss://browser-hostname doesn’t, but setting the host to the dev server’s host works in both cases.

4reactions
eminoscommented, Jun 24, 2022

This is probably not Valet related. I have the same issue serving the local dev site with Lando (Docker).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Valet - Not serving in browser - Laracasts
My valet sites are responding when using ping on command line but are refusing to serve in the browser. Any help would be...
Read more >
Server can not be found using Laravel Valet - Stack Overflow
Have linked a folder with valet link and secured it. But when trying in the browser I get the "Server not found..." error....
Read more >
laravel valet not serving any site - Reddit
Hi,I'm just clean install macOS 12.6 and reinstall everything fresh and want to serve my site via laravel valet. Everything was fine with...
Read more >
Laravel Valet - Laravel - The PHP Framework For Web Artisans
Once Valet is installed, try pinging any *.test domain on your terminal using a command such as ping foobar.test . If Valet is...
Read more >
Making Vite and Valet play nice together - Freek.dev
For each site, I usually run valet secure so the site loads over HTTPS. And that is what is causing problems. By default,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found