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.

Windows - Failed to load when loading vite dev server resources

See original GitHub issue
  • Laravel Vite Plugin Version: 0.2.3
  • Laravel Version: 9.x-dev (to include vite changes)
  • Node Version: 16.14.0
  • NPM Version: 8.4.1

Description:

In Windows, when loading the resources from Vite it fails to load as 0.0.0.0 is an invalid address in Windows and doesn’t get rerouted to 127.0.0.1 Chrome’s output: Failed to load resource: net::ERR_ADDRESS_INVALID 0.0.0.0:5173/@vite/client:1 Manually going into the generated hot file and changing the url to http://localhost:5173 instead of http://0.0.0.0:5173 allows all the files to load.

Steps To Reproduce:

Set up Laravel Vite Plugin as outlined in the UPRADE.md on Windows I’m using Laravel Sail (with the 5173 port mapped) through WSL, although I don’t know if that makes a difference. Due to the line setting host: ‘0.0.0.0’,, even changing the host in the vite.config.js file doesn’t help as it gets overwritten by this plugin.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:17
  • Comments:46 (7 by maintainers)

github_iconTop GitHub Comments

80reactions
jessarchercommented, Jun 29, 2022

I’m concerned about setting localhost in the hot file because on some machines this resolves to the IPv6 version (::1) and Docker doesn’t always listen on IPv6.

We could potentially set it to 127.0.0.1 to guarantee IPv4.

However, forcing a local address in the hot file would make things even harder if wanted to get sail share working with the Vite dev server.

There is maybe another option…

Vite allows you to configure where the client should look for the HMR server, using server.hmr. The Laravel Vite plugin should probably respect this, if set.

Would you mind testing against this branch?

https://github.com/laravel/vite-plugin/tree/use-hmr-host-when-set

I think you’ll want to set this in your vite.config.js (leaving server.host unset):

server: {
    hmr: {
        host: 'localhost',
    },
}
11reactions
amitleuva1987commented, Aug 24, 2022

@mariom9267 , did you try below?

server: {
    hmr: {
        host: 'localhost',
    },
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vite
Switch to another package manager (e.g. pnpm , yarn ); Remove & from the path to your project. Dev Server #. Requests are...
Read more >
Laravel Vite Issue - Laracasts
My application is using Inertia.js, and I've followed the migration guide from Laravel Mix to Vite. I'm fairly confident I have everything done...
Read more >
4 Ways to Fix the “Failed to Load Resource: net - Kinsta
Learn how to fix the "Failed to Load Resource: net::ERR_BLOCKED_BY_CLIENT" error. We'll show you 4 different methods to fix this error.
Read more >
Why Laravel Vite Directive Not Working in My Project?
Laravel 8 documentation says to install the laravel breeze using the following command. composer require laravel/breeze --dev.
Read more >
Making Vite and Valet play nice together - Freek.dev
dev codebase from Mix to Vite , npm dev could successfully start-up Vite, but in the browser the JS / CSS did not...
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 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