Skip to content

Commit ca54130

Browse files
committed
fix(server): resolve nuxt host localhost aliases
1 parent 5a86717 commit ca54130

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
| Statements | Branches | Functions | Lines |
99
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
10-
| ![Statements](https://img.shields.io/badge/Coverage-90.57%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-80.31%25-yellow.svg) | ![Functions](https://img.shields.io/badge/Coverage-92.86%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-90.57%25-brightgreen.svg) |
10+
| ![Statements](https://img.shields.io/badge/Coverage-90.63%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-79.84%25-red.svg) | ![Functions](https://img.shields.io/badge/Coverage-92.86%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-90.63%25-brightgreen.svg) |
1111

1212
Looking for the old CLI extension? [nuxt-laravel](https://github.com/m2sd/nuxt-laravel/tree/legacy).
1313

lib/module.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ const laravelModule = function (overwrites) {
128128
to avoid conflicts with dev server`);
129129
fs_extra_1.default.removeSync(config.output.dest);
130130
}
131+
const nuxtHost = ['0.0.0.0', '127.0.0.1'].includes(`${nuxtServer.host}`)
132+
? 'localhost'
133+
: nuxtServer.host;
131134
// retrieve dev server URL
132-
const nuxtUrl = new url_1.URL(config.nuxt.urlPath, `http${!!nuxtServer.https ? 's' : ''}://${nuxtServer.host}:${nuxtServer.port}`);
135+
const nuxtUrl = new url_1.URL(config.nuxt.urlPath, `http${!!nuxtServer.https ? 's' : ''}://${nuxtHost}:${nuxtServer.port}`);
133136
// try to start artisan server from Laravel path
134137
utils_1.logger.debug(`Nuxt url: ${nuxtUrl.href}`);
135138
utils_1.logger.debug(`Laravel url: ${laravelUrl.href}`);

src/module.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ const laravelModule: Module<Options> = function(overwrites) {
201201
fs.removeSync(config.output.dest)
202202
}
203203

204+
const nuxtHost = ['0.0.0.0', '127.0.0.1'].includes(`${nuxtServer.host}`)
205+
? 'localhost'
206+
: nuxtServer.host
207+
204208
// retrieve dev server URL
205209
const nuxtUrl = new URL(
206210
config.nuxt.urlPath,
207-
`http${!!nuxtServer.https ? 's' : ''}://${nuxtServer.host}:${
211+
`http${!!nuxtServer.https ? 's' : ''}://${nuxtHost}:${
208212
nuxtServer.port
209213
}`
210214
)

0 commit comments

Comments
 (0)