Skip to content
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

Allow serving local environment from any address #662

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

gudmundurh
Copy link
Member

@gudmundurh gudmundurh commented Jan 3, 2025

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, or tailscale funnel to serve on the internet:

➜  ~ tailscale serve https://localhost:9000
Available within your tailnet:

https://your-computer-name.tail492ec.ts.net/
|-- proxy https://localhost:9000

Tailscale assigns a unique hostname to the app, in this example your-computer-name.tail492ec.ts.net. This you put into the PUBLIC_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. to https://<your IP>:9000 . This is not ideal however, as the local development TLS certificate will not match the address, and as this currently requires applicationUrl in launchSettings.json in the AppGateway to be set to listen on any 0.0.0.0.

Downstream Projects

Projects that are using PlatformPlatform need to make the following changes:

  1. For each self-contained system, remove PUBLIC_URL and CDN_URL from launchSettings.json in the API and Worker projects
  2. Then, for each project, call WithUrlConfiguration in AppHost/Program.cs like this:
var yourSelfContainedSystemApi = builder
    .AddProject<YourSelfContainedSystem_Api>("your-self-contained-system-api")
    .WithUrlConfiguration("/your-self-contained-system")
    ....

Checklist

  • I have added tests, and done manual regression tests
  • I have updated the documentation, if necessary

@gudmundurh gudmundurh changed the title Configure PUBLIC_URL only in the gateway. Allow serving local environment from any address Jan 3, 2025
@gudmundurh gudmundurh requested a review from tjementum January 3, 2025 15:14
@tjementum tjementum added the Enhancement New feature or request label Jan 4, 2025
@tjementum tjementum force-pushed the serve-local-env-from-any-address branch 2 times, most recently from 2b35157 to 69a5ff7 Compare January 5, 2025 17:10
@gudmundurh gudmundurh force-pushed the serve-local-env-from-any-address branch from 69a5ff7 to e81975f Compare January 7, 2025 08:42
@gudmundurh gudmundurh force-pushed the serve-local-env-from-any-address branch from e81975f to 2eba26f Compare January 7, 2025 08:44
@gudmundurh
Copy link
Member Author

Quality Gate Failed Quality Gate failed

Failed conditions 8.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@tjementum Can you have a look? This quality check issues not related to the changes in this PR.

@gudmundurh gudmundurh force-pushed the serve-local-env-from-any-address branch from 0eab6f5 to ed2eb31 Compare January 7, 2025 09:45
@tjementum tjementum force-pushed the serve-local-env-from-any-address branch from ed2eb31 to 2eba26f Compare January 7, 2025 11:00
Copy link

sonarqubecloud bot commented Jan 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
8.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@tjementum tjementum merged commit 924d83f into main Jan 7, 2025
28 of 29 checks passed
@tjementum tjementum deleted the serve-local-env-from-any-address branch January 7, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants