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

ignaciodev's avatar

Vite dev does not work in Safari Mac

On a fresh Laravel installation (with Laravel Breeze React), when I run npm run dev, and visit http://localhost, everything works great on Chrome. But on Safari it never works. All I see is a blank screen, and this on the console:

[Error] Failed to load resource: bad URL (@react-refresh, line 0)
[Error] Failed to load resource: bad URL (app.jsx, line 0)
[Error] Failed to load resource: bad URL (Welcome.jsx, line 0)
[Error] Failed to load resource: bad URL (client, line 0)

My Mac is only 1 year old, very up to date.

0 likes
8 replies
martinbean's avatar

@ignaciodev I run Laravel projects, and Vite, on both Intels and an M2 MacBook Pros, and never had an issue.

Can you show a screenshot of the errors in the Safari web inspector console?

ignaciodev's avatar
ignaciodev
OP
Best Answer
Level 2

I found a workaround by modifying my vite.config.js adding this before plugins:

server: {
    hmr: {
        host: 'localhost',
    },
},

It now renders on Safari.

3 likes
thinkverse's avatar

Tested Laravel Breeze with both Herd/Valet and Sail on Macbook PRO with M2 PRO and could not reproduce this issue. Even running the Sail container and starting Vite from outside the container worked without issue.

That's not much of a consolation but at least you know. 🤷‍♂️

ignaciodev's avatar

@thinkverse yes, it's bizarre 🤔 I found a Github thread where a bunch of devs were experiencing the same issue as me, while some others could not reproduce the issue at all.

The vite.config.js modification workaround seems to do the trick I guess.

1 like
jimmitjoo's avatar

@josemflores thank you. This solved my issue.

If someone else finds this: Safari blocked the vite files which was referenced through an insecure http://localhost connection instead of through the valet ssl domain. Adding detectTls: 'domain.test' to the laravel config in vite.config.js solved it. Check out the link @josemflores posted above.

1 like

Please or to participate in this conversation.