Skip to content

Commit 3332280

Browse files
Merge pull request #443 from welderlourenco/document-laravel-eer-empty-response
Created documentation for net::ERR_EMPTY_RESPONSE issue in Laravel Mix\Laravel Vite
2 parents 2f0ee07 + 3566678 commit 3332280

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### `kool run npm run hot` or `kool run npm run dev`
2+
3+
> Also valid for `kool run yarn run hot` or `kool run yarn run dev`
4+
5+
**Problem:**
6+
7+
> Browser cannot request "HMR" (hot module replacement) server successfully in Laravel Mix or Laravel Vite.
8+
9+
> Console errors: **net::ERR_CONNECTION_REFUSED** or **net::ERR_EMPTY_RESPONSE**.
10+
11+
**Answer:**
12+
13+
> Publish the HMR's port to the host and change HMR settings to listen on all IPv4 addresses (`0.0.0.0`).
14+
15+
For the sake of clarity, let's elect port `8080` to publish.
16+
17+
In your `kool.yml`, apply the following changes:
18+
19+
```diff
20+
-npm: kool docker kooldev/node:16 npm
21+
+npm: kool docker -p 8080:8080 kooldev/node:16 npm
22+
```
23+
24+
- Alternatively, if you don't want to publish the port for your general `kool run npm` commands, you may add a new entry.
25+
26+
**> Laravel Mix**
27+
28+
In your `webpack.mix.js`, include the following changes to the `mix.options` call.
29+
30+
```diff
31+
mix.options({
32+
+ hmrOptions: {
33+
+ host: '0.0.0.0',
34+
+ port: 8080,
35+
+ },
36+
});
37+
```
38+
39+
**> Laravel Vite**
40+
41+
In your `vite.config.js` file, include the following changes to the `defineConfig` call.
42+
43+
```diff
44+
export default defineConfig({
45+
+ server: {
46+
+ host: '0.0.0.0',
47+
+ port: 8080,
48+
+ },
49+
plugins: [
50+
laravel({
51+
input: ['resources/css/app.css', 'resources/js/app.js'],
52+
refresh: true,
53+
}),
54+
],
55+
});
56+
```

0 commit comments

Comments
 (0)