Resolve API URL for Codespaces port forwarding#18
Merged
Conversation
GitHub Codespaces forwards each port as its own subdomain (e.g.
name-5300.app.github.dev) served over 443, not as host:port. The client
built the API URL as `${hostname}:5300`, producing
name-4200.app.github.dev:5300, which is unreachable (ERR_ADDRESS_UNREACHABLE).
Move the URL resolution into a small pure helper (resolveApiBaseUrl in
api-url.ts) that transparently rewrites the forwarded-port host, so the
service just asks for a base URL and the port-forwarding detail stays
encapsulated. Local host:5300 behavior is unchanged.
sis0k0
force-pushed
the
fix-codespaces-api-url
branch
2 times, most recently
from
July 25, 2026 07:13
04a7d93 to
d24be04
Compare
sis0k0
force-pushed
the
fix-codespaces-api-url
branch
from
July 25, 2026 07:28
d24be04 to
30a60f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
In Codespaces, creating an employee fails:
Root cause
ApiConfigServicebuilt the API base URL as${window.location.hostname}:5300. In Codespaces the client host is…-4200.app.github.dev, so this produced…-4200.app.github.dev:5300. Codespaces doesn't expose ports as:porton the same host — each forwarded port is a separate subdomain (…-5300.app.github.dev) served over 443. Thehost:5300URL therefore resolves to nothing.Fix
When the host ends with
.app.github.dev, swap the port segment (-4200→-5300) and use the default (443) port; keep${hostname}:5300for local development.Verification
ng buildpasses.…-4200.app.github.dev→https://…-5300.app.github.dev;localhost→http://localhost:5300..devcontainer/portSetup.sh, and the server enables permissive CORS.