berhir / AspNetCore.SpaYarp

An alternative approach to the new ASP.NET Core SPA templates in .NET 6. It uses YARP as proxy to forward requests to the SPA dev server.
MIT License
99 stars 12 forks source link

vite websocket connection not working #14

Closed marc3lsk closed 2 years ago

marc3lsk commented 2 years ago

https://github.com/marc3lsk/AspNetReactViteSpaYarp

In this repo I tried to make my client app with vite+react. When I run the dotnet app and navigate to its URL I can see my react app but it keeps reloading periodically. It seems that connection to vite WebSocket localhost:3000 is not working. How could this be fixed?

marc3lsk commented 2 years ago

I was able to fix this issue by adjusting the vite config and startup script https://github.com/marc3lsk/AspNetReactViteSpaYarp/commit/3a4dc4580dfecedbf6a4a51c40b348b03b36f3a4

I figured it out thanks to this article https://blogs.taiga.nl/martijn/2021/02/24/integrating-vite-with-asp-net-core-a-winning-combination/

berhir commented 2 years ago

Thanks for sharing @marc3lsk! If you want, I can create a samples section in the readme and link to your repo.

marc3lsk commented 2 years ago

No problem! I don't mind if you would like to use my repo as an example.