Skip to content

Commit 5162674

Browse files
Include base in hotFile without modifying server.origin replacement (#296)
* Include base in hotFile without modifying server.origin replacement * Formatting --------- Co-authored-by: Tim MacDonald <[email protected]>
1 parent 908b775 commit 5162674

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ interface LaravelPlugin extends Plugin {
8484
config: (config: UserConfig, env: ConfigEnv) => UserConfig
8585
}
8686

87-
type DevServerUrl = `${'http'|'https'}://${string}:${number}${string}`
87+
type DevServerUrl = `${'http'|'https'}://${string}:${number}`
8888

8989
let exitHandlersBound = false
9090

@@ -204,7 +204,8 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
204204
const isAddressInfo = (x: string|AddressInfo|null|undefined): x is AddressInfo => typeof x === 'object'
205205
if (isAddressInfo(address)) {
206206
viteDevServerUrl = userConfig.server?.origin ? userConfig.server.origin as DevServerUrl : resolveDevServerUrl(address, server.config, userConfig)
207-
fs.writeFileSync(pluginConfig.hotFile, viteDevServerUrl)
207+
208+
fs.writeFileSync(pluginConfig.hotFile, `${viteDevServerUrl}${server.config.base.replace(/\/$/, '')}`)
208209

209210
setTimeout(() => {
210211
server.config.logger.info(`\n ${colors.red(`${colors.bold('LARAVEL')} ${laravelVersion()}`)} ${colors.dim('plugin')} ${colors.bold(`v${pluginVersion()}`)}`)
@@ -431,9 +432,8 @@ function resolveDevServerUrl(address: AddressInfo, config: ResolvedConfig, userC
431432

432433
const configHmrClientPort = typeof config.server.hmr === 'object' ? config.server.hmr.clientPort : null
433434
const port = configHmrClientPort ?? address.port
434-
const base = config.base.replace(/\/$/, '')
435435

436-
return `${protocol}://${host}:${port}${base}`
436+
return `${protocol}://${host}:${port}`
437437
}
438438

439439
function isIpv6(address: AddressInfo): boolean {

0 commit comments

Comments
 (0)