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.
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..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With