question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SWA CLI stopping without error msg when using Blazor WASM dev server over https

See original GitHub issue

Are you accessing the CLI from the default port :4280 ?

  • No, I am using a different port number (--port) and accessing the CLI from that port
  • Yes, I am accessing the CLI from port :4280

Describe the bug When trying to use the SWA CLI with a dotnet Blazor application running on https the SWA CLI quits when the index page is accessed (see below for traces from various node versions)

When accessing the http endpoint of the Blazor development server it works as expected

I’ve tried this on both Windows and macOS with the same result

To Reproduce Steps to reproduce the behavior:

  1. Clone the https://github.com/Apress/beginning-azure-static-web-apps repo
  2. Open the chapter-5 folder
  3. Run swa start https://localhost:5000 --api-location ./Api --run "dotnet watch run --project ./Client"
  4. Open http://localhost:4280/
  5. SWA CLI quits without error (in the most recent versions of Node)

Expected behavior The application should load in the browser as it does with the http endpoint

Desktop (please complete the following information):

  • OS: Windows 11, macOS Ventura 13.0
  • SWA CLI Version: 1.0.3

Additional context When downgrading the SWA CLI to 1.0.2 the application works as expected

I tried downgrading Node to see if that had an impact. It did - but only in that running Node 14.x there is an error message displayed. If I build and run the SWA CLI on my machine removing the code that gracefully shuts down the SWA CLI then I can also get this error message on Node 16 (I didn’t try on 18.x)

Downgrading Node to 14.21.1 I get the following:

(node:12156) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
[swa]     at new NodeError (internal/errors.js:322:7)
[swa]     at new ClientRequest (_http_client.js:159:11)
[swa]     at Object.request (https.js:370:10)
[swa]     at Array.stream (C:\code\github\static-web-apps-cli\node_modules\http-proxy\lib\http-proxy\passes\web-incoming.js:126:74)
[swa]     at ProxyServer.<anonymous> (C:\code\github\static-web-apps-cli\node_modules\http-proxy\lib\http-proxy\index.js:81:21)
[swa]     at serveStaticOrProxyResponse (C:\code\github\static-web-apps-cli\dist\msha\middlewares\request.middleware.js:97:18)
[swa]     at requestMiddleware (C:\code\github\static-web-apps-cli\dist\msha\middlewares\request.middleware.js:246:9)
[swa]     at Server.<anonymous> (C:\code\github\static-web-apps-cli\dist\msha\server.js:42:58)
[swa]     at Server.emit (events.js:400:28)
[swa]     at parserOnIncoming (_http_server.js:900:12)
[swa]     at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)

On Node 16.18.1 and 18.12.1 I get the following

[swa] remote dev server detected.
[swa]  - url: /
[swa]  - target: https://localhost:5000
[swa] customUrl: false
[swa] is4xx: false
[swa] remote dev server detected. Proxying request
[swa]  - url: /
[swa]  - code: 200
[swa] GET https://localhost:5000/ (proxy)
[swa] killing SWA CLI
[swa] node "C:\Users\s.cashmore\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\msha\server.js" exited with code 0

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
manekinekkocommented, Nov 24, 2022
1reaction
manekinekkocommented, Nov 24, 2022

Aside from the worry of the MAC issue, doi you have anything against the idea of @anthonychu to use the dev server URL to decide whether to use https or not?

I am not against it. If MAC is not an issue here, then @anthonychu’s suggestion is part of the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Static Web Apps CLI work with my blazor client app with ...
[run] cd "C:\GitHub\zzz\Client" && dotnet watch run exited with code 1 ✖ SWA emulator stoped because the --run command exited with code 1....
Read more >
Securing a Blazor WASM app on Azure Static Web App - Part 1
Providing only the SSL option to the CLI did not work. SWA CLI option SSL fails with a message to provide key and...
Read more >
Troubleshooting | Static Web Apps CLI - Azure documentation
This page lists frequently-asked questions and solutions to help troubleshoot common issues that may be encountered when building or testing the project.
Read more >
Securing an Azure Static Web App with Auth0 Actions
Alas, I am encountering HTTP 500 errors on Azure SWA when incorporating this feature. Azure SWA displaying a message about internal server error....
Read more >
Prerendering Blazor Wasm application with ABP 6.x
In this article, we will demonstrate how to create basic hosted monolith Blazor WebAssembly application that will be prerendered by the server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found