-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support bring-you-own-function projects for swa start #523
Comments
Ensure the correct default port is parsed from http and https URLs. Before this change, URLs used to identify remote API servers might be parsed as using port 0. swa-cli would then attempt to make a TCP connection to port 0 and would eventually timeout. With this change, ports for remote API servers are now correctly identified and connections are made to the server without the timeout occuring. Relates to Azure#523
Ensure the correct default port is parsed from http and https URLs. Before this change, URLs used to identify remote API servers might be parsed as using port 0. swa-cli would then attempt to make a TCP connection to port 0 and would eventually timeout. With this change, ports for remote API servers are now correctly identified and connections are made to the server without the timeout occuring. Relates to #523
Fixed by #524 |
@sgollapudi77 - this is not complete - still two other items that need to be addressed. Please see last part of the issue text and reopen. I'm working on the other items at the moment. |
Allow insecure connections to remote api hosts to handle cases where remote TLS host presents a wildcard certificate. Change the host header in proxied requests from localhost to match the remote api host. Relates to Azure#523
Thank you @danwatford for identifying this issue and working on it. |
commit 02fdb90 Author: Yohan Lasorsa <[email protected]> Date: Fri Dec 16 10:09:48 2022 +0100 fix: --api-devserver-url not working if --api-location not set (#523, #579) (#620) * fix: --api-devserver-url not working if --api-location not set (#523, #579) * docs: fix documentation regarding --api-devserver-url usage (#579) commit 7ecbae2 Author: Reshmi Sriram <[email protected]> Date: Thu Dec 15 13:10:12 2022 +0530 docs: Add firewall section to troubleshoot (#618) * Added firewall section * updated the message commit eee1263 Author: BeardinaSuit <[email protected]> Date: Sun Dec 11 23:54:32 2022 -0500 fix: handle new provider name when deploying (#617) commit 27ec687 Author: Stuart Leeks <[email protected]> Date: Tue Dec 6 09:40:07 2022 +0000 Fix typo (#605) fix: typo in CONTRIBUTING.md commit 9c43aa8 Author: Stuart Leeks <[email protected]> Date: Tue Dec 6 09:38:51 2022 +0000 Update title (#606) docs: In the doc content this is referred to as the "configuration file" and this feels like a more natural title commit 97e9461 Merge: 08ac26c ac6909a Author: Rupa Reddy <[email protected]> Date: Tue Dec 6 13:06:18 2022 +0530 Merge pull request #614 from Azure/origin/rupareddy/LoginCC fix(login): fixed short-form of --clear-credentials flag commit 08ac26c Merge: 2cd0e98 6d1ad19 Author: Rupa Reddy <[email protected]> Date: Tue Dec 6 12:59:29 2022 +0530 Merge pull request #613 from Azure/origin/rupareddy/FixRGName fix(deploy): create SWA in user-provided Resource Group commit 6d1ad19 Author: rupareddy5 <[email protected]> Date: Mon Dec 5 14:57:37 2022 +0530 fix: to fix the inability to create a SWA in user-mentioned resource group, changed all the resourceGroupName references to resourceGroup in the code to match with --resource-group flag. commit ac6909a Author: rupareddy5 <[email protected]> Date: Mon Dec 5 13:34:00 2022 +0530 fixed short-form of --clear-credentials flag commit ca856be Author: rupareddy5 <[email protected]> Date: Fri Dec 2 16:17:38 2022 +0530 create SWA in user-provided Resource Group commit 2cd0e98 Author: sgollapudi77 <[email protected]> Date: Wed Nov 9 11:32:46 2022 +0530 chore: upgrade dependency version to fix security vulnerability (#597) * chore: upgrade dependency version to fix security vulnerability * chore: upgrade integrity of package commit 3bdc5f1 Author: sgollapudi77 <[email protected]> Date: Sun Oct 9 16:34:22 2022 +0530 chore: bump into 1.0.4-alpha after release (#586) commit 5ab32a7 Merge: b4fbf3a a6f08e3 Author: Sulabh Upadhyay <[email protected]> Date: Fri Oct 7 14:15:35 2022 +0530 Merge pull request #585 from Azure/all-contributors/add-rupareddy5-21 docs: add rupareddy5-21 as a contributor for code commit a6f08e3 Author: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri Oct 7 08:20:26 2022 +0000 docs: update .all-contributorsrc commit b461129 Author: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri Oct 7 08:20:25 2022 +0000 docs: update docs/www/docs/contribute/3-contributors.md commit b4fbf3a Author: sgollapudi77 <[email protected]> Date: Fri Oct 7 12:51:28 2022 +0530 ci: Remove Node 12 from the testing matrix (#584) commit 4b0114b Author: sgollapudi77 <[email protected]> Date: Fri Oct 7 12:01:04 2022 +0530 chore: prep-release 1.0.3 (#583) commit 4af9624 Author: Wassim Chegham <[email protected]> Date: Fri Oct 7 07:30:23 2022 +0200 docs: update troubleshooting with explainer #576 (#581) commit 70c126e Author: Wassim Chegham <[email protected]> Date: Fri Oct 7 07:30:03 2022 +0200 docs: add valid azure regions for SWA (#582) * docs: add valid azure regions for SWA * docs: update azure regions commit 6004141 Author: Wassim Chegham <[email protected]> Date: Thu Oct 6 08:52:36 2022 +0200 fix(core): match * glob in routes (#574) Fixes #569 commit d24df7a Author: Aaron Powell <[email protected]> Date: Thu Oct 6 17:51:46 2022 +1100 fix(api): bumping the node support to 18 for v4 functions (#564) commit 1fec77e Merge: 19c619b 2771906 Author: Rupa Reddy <[email protected]> Date: Thu Oct 6 11:38:36 2022 +0530 Merge pull request #577 from rupareddy5-21/main Updating deployment provider commit 2771906 Author: Rupa Reddy <[email protected]> Date: Thu Sep 29 16:34:22 2022 +0530 Updating Deployment provider commit 1b7fabd Author: Rupa Reddy <[email protected]> Date: Thu Sep 29 16:33:02 2022 +0530 updating Deployment provider commit 19c619b Author: Natalia Venditto <[email protected]> Date: Mon Sep 26 15:13:12 2022 +0200 docs: add default port for vite-based frameworks (#571) commit 47823b0 Merge: 06356c1 7e021c7 Author: Sulabh Upadhyay <[email protected]> Date: Fri Sep 16 15:05:06 2022 +0530 Merge pull request #560 from Azure/swa-start-perf-boost fix(start): keep connection open with http-proxy commit 06356c1 Author: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed Sep 14 23:10:22 2022 +0530 docs: add thsackos as a contributor (#561) * docs: update docs/www/docs/contribute/3-contributors.md * docs: update .all-contributorsrc Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> commit 8b7d725 Author: thsackos <[email protected]> Date: Wed Sep 14 06:13:25 2022 -0700 fix(cli): implement missing response override referrer behavior (#543) The documentation calls out user-defined redirect behavior using the .referrer parameter in the response override configuration. This PR enables the SWA CLI emulator to support that functionality. Fixes #542 commit 7e021c7 Author: Wassim Chegham <[email protected]> Date: Wed Sep 14 12:19:03 2022 +0200 fix(start): keep connection open with http-proxy
Please finish this, it's very important for us |
Are there any news regarding this issue? We are also facing problems trying to work locally in the front-end app pointing to the remote azure function. |
Is your feature request related to a problem? Please describe.
To develop static web apps with functions that take advantage of managed identity it is necessary to deploy the functions to an functions-app separate to the swa-app and then link them together. This is referred to in the documentation as Bring Your Own Functions.
A solution which makes use of Bring Your Own Functions will often use two git repositories to store the SWA and the function-app sources.
With remote development approaches such as codespaces or docker containers becoming more common, it is likely that the developer will find themselves running/debugging the SWA and the function-app on different network hosts. They may also deploy the function-app to Azure and want to run/debug their SWA app locally.
When the function-app is running on a different network host to the swa-cli, the developer will need to specify the URL to the function-app as an HTTPS URL. Currently the swa-cli does not support this use case, but can be made to do so with a few changes.
Describe the solution you'd like
Support proxying of API requests to APIs hosted on remote hosts, using HTTPS URLs.
Allow use of insecure connections to the remote API similar to the
-k | --insecure
command line option in curl. This is to handle the case where the API host is using wildcard certificates which do not appear to be accepted by the http-proxy node module used by swa-cli.When proxying requests to the remote function-app, swa-cli should rewrite the host header to match the URL of the function app. Without this the function-app host will receive a request with a Host header of /localhost/ and will respond with a 404.
Describe alternatives you've considered
When running the function-app in GitHub codespaces, port 7071 can be shared publicly. I tried making this available over HTTP, but this does not appear to supported for public ports.
VS Code will forward ports in codespaces to the local development host. I then tried using ngrok to make the local port available at a public HTTP URL which could be accessed by the swa-cli running in another codespace, but ran into connection issues around wildcard TLS certs used by ngrok.
Additional context
Setting a remote URL with the
--api-location option
toswa-cli start
causes swa to attempt to resolve the URL as a filesystem directory. It is necessary to also specify the--api-devserver-url
option.However specifying
--api-devserver-url
only causes swa-cli to not be aware of any API server settings since conditional logic prevent--api-devserver-url
being examined if--api-location
is not also specified. Therefore in testing (of updates to swa-cli) I had to use command lines similar to:Changes needed to support this use case
net.ts
parseUrl
function should return port 443 for HTTPS URLs. Currently it returns 0 which causes a timeout in subsequent connection checking. See https://nodejs.org/dist/latest-v16.x/docs/api/url.html#urlport which explains the parsed port from a URL can be an empty string. PR fix(core): identify correct default port for http and https urls #524 merged.(Update 2022-10-03: No longer needed. Only the host header change, mentioned below, is necessary for TLS connections to remote API hosts)msha/handlers/function.handler.ts
should optionally callhttpProxy.createProxyServer
with{ secure: false }
to prevent connections to remote function-apps failing due to wildcard TLS certificates. Addressed in PR feat(start): allow insecure https connections to remote api hosts #534.msha/handlers/function.handler.ts
injectHeaders
function should set thehost
header to match the host of the remote function-app. Without this change thehost
header will remain set tolocalhost
and proxied request will likely fail to get routed corrected at the remote host. Addressed in PR feat(start): set host header in proxied requests to match remote API hosts #578.With the above changes I was able to connect swa-cli to a remote function-app addressed via an HTTPS URL.
The text was updated successfully, but these errors were encountered: