Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug Blazor WASM apps running behind SWA CLI?

I have a Blazor WASM app (.NET 6). I use SWA CLI to emulate the Azure Static Web App env locally. I can debug Blazor WASM when I run it alone, but I need SWA CLI because there are auth features there. Is it possible to debug it?

I try to run something like

swa start http://localhost:5001 --api-location http://localhost:7071

I run my Azure Functions on the other process, and I start a debugging Visual Studio 2022 session. But breakpoints are not hit in Visual Studio.

Another try:

swa start http://localhost:5001 --run "dotnet watch run" --api-location http://localhost:7071

This time I let SWA CLI run the Blazor app. Then I use "Attach to a process" feature of Visual Studio 2022. To no avail, too.

So... How do I debug a Blazor WASM app behind SWA CLI proxy? Many thanks.

like image 322
Lam Le Avatar asked Jun 22 '26 21:06

Lam Le


1 Answers

I had the exact same problem.

Searching for an answer, I came across the following article which explains into great detail how to solve our problem 😀

https://www.intertech.com/part-1-of-3-azure-static-web-apps-blazor-webassembly-front-end-and-c-azure-functions-back-end-local-development-first-method/

You have to start the swa cli as you mentioned, pointing to the localhost urls. But then what links it all thoghether is adding the launchUrl setting to the client launchSettings.json file. That setting should be the url of the swa cli host, by default "http://localhost:4280". After setting that, it all started working for me.

Hope it helps..

like image 186
schepersk Avatar answered Jun 25 '26 20:06

schepersk