Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ufodisko's avatar
Level 10

error during build: TypeError: Invalid URL

I created a fresh laravel projects using Jetstream Livewire but I'm unable to build the assets.

Running npm run dev or npm run build gives this error

error when starting dev server / error during build::
TypeError: Invalid URL
    at new URL (node:internal/url:818:25)
    at getAdditionalAllowedHosts (file:///C:/Users/User/Projects/traveler/node_modules/vite/dist/node/chunks/dep-CjorC8P2.js:59194:29)
    at resolveConfig (file:///C:/Users/User/Projects/traveler/node_modules/vite/dist/node/chunks/dep-CjorC8P2.js:66549:29)
    at async _createServer (file:///C:/Users/User/Projects/traveler/node_modules/vite/dist/node/chunks/dep-CjorC8P2.js:62901:18)
    at async CAC.<anonymous> (file:///C:/Users/User/Projects/traveler/node_modules/vite/dist/node/cli.js:736:20)

Node: v22.13.0

NPM: v11.0.0

This is my package.json

{
    "private": true,
    "type": "module",
    "scripts": {
        "build": "vite build",
        "dev": "vite"
    },
    "devDependencies": {
        "@tailwindcss/forms": "^0.5.7",
        "@tailwindcss/typography": "^0.5.10",
        "autoprefixer": "^10.4.16",
        "axios": "^1.7.4",
        "concurrently": "^9.0.1",
        "laravel-vite-plugin": "^1.0",
        "postcss": "^8.4.32",
        "tailwindcss": "^3.4.0",
        "vite": "^6.0"
    }
}

I deleted the project and installed a new one, and I'm still facing the same error. This is the first time I face such an error.

1 like
10 replies
Sinnbeck's avatar

Do you have a host set up in your vite config file?

This is mine

server: {
            host: true,
            port: 3009,
            hmr: {host: 'localhost', protocol: 'ws'},
        },
ufodisko's avatar
Level 10

@Sinnbeck I do not have a host set up, but I added your suggestion to my vite config file and it's still not working. Same error as always.

alanost's avatar

I also get this error with a newly set up project. Also in the Docker container. I wanted to try Laravel for the first time today, I think something is broken. I searched the internet for hours until I came across this post.

ufodisko's avatar
Level 10

I downgraded vite to 5.1.4 or 6.0.8 and it works, I can now run npm run dev and npm run build

npm install [email protected] --save-dev

Looks like Vite v6 is not working properly.

9 likes
MartynasKi's avatar

Whew! And I thought it was only me having this strange error 😅

So, temp solution seems to be downgrading to vite 6.0.8:

npm install [email protected] --save-dev

-- OR --

you can add these settings in vite.config.js :

export default defineConfig({
    server: {
        origin: 'https://your-herd-project.test:5173',
        cors: true,
   }
1 like
CharlesGichira's avatar

Just ran into this problem a few hours ago. I thought my computer was broken, restarted with no luck just noticed it an external problem. Thank you for sharing.

1 like

Please or to participate in this conversation.