dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.4k stars 10k forks source link

Hot reloading with SPA proxy #44403

Open jasonhilldm opened 2 years ago

jasonhilldm commented 2 years ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

I am trying to get hot reloading working with the SPA proxy using the React.js project template in Visual Studio 2022 for Mac. If you run the project with dotnet watch and then make changes to the backend API code, then the project is recompiled but the SPA proxy is killed so the front end stops working.

You can run the project normally within Visual Studio and then the front end hot reloads when you make changes to the React code, but you have to manually restart the application when you make changes to the backend code.

There doesn't seem to be a way to have hot reloading working for both front and and back end code.

Describe the solution you'd like

It would be great if the SPA proxy is not killed after the hot reload or maybe just restarted so that the front end is still operational without having to manually restart it.

Additional context

No response

javiercn commented 2 years ago

@jasonhilldm thanks for contacting us.

I believe we have an issue in our backlog to allow keeping the proxy alive, but in this scenario what we recommend is that you launch the frontend proxy manually from the CLI and keep it running in the background.

We automatically kill the proxy when we launch it because we do not want to leave orphaned processes behind.

ghost commented 2 years ago

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

jasonhilldm commented 2 years ago

Yeah, that's how we've done it in other projects...starting the frontend proxy manually from the CLI and then running dotnet watch from another terminal to support hot reloading of the backend code. That's a bit annoying to have to do that manually every time though, so I was hoping that the SPA proxy middleware would provide a managed way to run both the frontend and backend pieces with hot reloading in both.

It would be nice if the frontend proxy was restarted when the backend is recompiled although that would be a bit slower compared to leaving the frontend proxy running when the backend is recompiled. If the backend is stopped though, then I can see why you would want to kill the frontend proxy too so that processes are not left running.

ghost commented 1 year ago

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.