SWA CLI stopping without error msg when using Blazor WASM dev server over https
See original GitHub issueAre 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:
- Clone the
https://github.com/Apress/beginning-azure-static-web-apps
repo - Open the
chapter-5
folder - Run
swa start https://localhost:5000 --api-location ./Api --run "dotnet watch run --project ./Client"
- Open
http://localhost:4280/
- 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:
- Created 10 months ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top GitHub Comments
Awesome! Could you also try with examples from https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content#loading_locally_delivered_mixed-resources?
I am not against it. If MAC is not an issue here, then @anthonychu’s suggestion is part of the fix.