Allow serving local environment from any address #662
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
Up to now, it has been hard to test the web app on other devices, as the code was hard coded to the web app being at
localhost:9000
, thus allowing only tests from the computer where development takes place. With this change,PUBLIC_URL
can be configured for the AppGateway to allow serving the app on any address, allowing testing on multiple devices.This allows using a reverse proxy tool, such as ngrok or Tailscale, to serve the local web app on address of your choice. With Tailscale you can use
tailscale serve
to serve on your Tailscale network, ortailscale funnel
to serve on the internet:Tailscale assigns a unique hostname to the app, in this example
your-computer-name.tail492ec.ts.net
. This you put into thePUBLIC_URL
environment variable for the AppHost project.Alternatively, this can be used without a reverse proxy tool, to serve directly on your local network: Set
PUBLIC_URL
e.g. tohttps://<your IP>:9000
. This is not ideal however, as the local development TLS certificate will not match the address, and as this currently requiresapplicationUrl
inlaunchSettings.json
in the AppGateway to be set to listen on any0.0.0.0
.Downstream Projects
Projects that are using PlatformPlatform need to make the following changes:
PUBLIC_URL
andCDN_URL
fromlaunchSettings.json
in the API and Worker projectsWithUrlConfiguration
inAppHost/Program.cs
like this:Checklist