andrefelipe / vite-php-setup

Example on how to run Vite on traditional PHP sites
https://github.com/vitejs/vite
358 stars 52 forks source link

WebSocket connection failed #5

Closed k07n closed 3 years ago

k07n commented 3 years ago

Hi! Can you explain why this would happen, please?

ws-error

andrefelipe commented 3 years ago

Sorry I never used WebSockets with Vite yet.

k07n commented 3 years ago

Oh, so you have this error too (and infinite page refresh)? I've clone this repo, install, link assets and run, no other changes was made. ANY thoughts where I was missed something?

k07n commented 3 years ago

I've got this! hmr was connecting to "public host", but must to localhost, so server.hmr little configuration helps:

server {
    hmr: {
     port:3000,
     host: "localhost",
    }
}

ps: thx for your job, great php-setup ;)

McSmog commented 3 years ago
server {
    hmr: {
     port:3000,
     host: "localhost",
    }
}

I had an error until I added the protocol:

  server: {
    hmr: {
      port: 3000,
      protocol: 'ws',
      host: 'localhost',
    },
  },

thx k07n

andrefelipe commented 3 years ago

Hello @k07n sorry for not answering, I have been very busy.

Strange, I never had yet to change the "server.hmr" options. Don't know why yet. Have already done 5 projects with this kind of setup. Maybe something to do with the web server. I use Laravel Valet.

Thanks for looking into it!