Skip to content

Commit

Permalink
[1.x] Fix Invalid URL issue with Vite 6.0.9 (#317)
Browse files Browse the repository at this point in the history
* [1.x] Fix Invalid URL issue with Vite 6.0.9

This PR resolves the "Invalid URL" error that occurred due to the requirement that the server.origin value be a URL, introduced in the recently released Vite 6.0.9.

* Update placeholder url

* Replace the correct placeholder

---------

Co-authored-by: Tim MacDonald <hello@timacdonald.me>
  • Loading branch information
batinmustu and timacdonald authored Jan 21, 2025
1 parent e57a940 commit 1501f5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0,
},
server: {
origin: userConfig.server?.origin ?? '__laravel_vite_placeholder__',
origin: userConfig.server?.origin ?? 'http://__laravel_vite_placeholder__.test',
...(process.env.LARAVEL_SAIL ? {
host: userConfig.server?.host ?? '0.0.0.0',
port: userConfig.server?.port ?? (env.VITE_PORT ? parseInt(env.VITE_PORT) : 5173),
Expand Down Expand Up @@ -190,7 +190,7 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
},
transform(code) {
if (resolvedConfig.command === 'serve') {
code = code.replace(/__laravel_vite_placeholder__/g, viteDevServerUrl)
code = code.replace(/http:\/\/__laravel_vite_placeholder__\.test/g, viteDevServerUrl)

return pluginConfig.transformOnServe(code, viteDevServerUrl)
}
Expand Down

0 comments on commit 1501f5c

Please sign in to comment.