Skip to content

Conversation

@christian-kreuzberger-dtx
Copy link
Collaborator

@christian-kreuzberger-dtx christian-kreuzberger-dtx commented Oct 24, 2025

The problem is that on GH Codespaces, localhost is not an address that we can use, as this runs somewhere in the cloud.
Luckily, there is a fix for this ^^

Proof:
image

@christian-kreuzberger-dtx christian-kreuzberger-dtx marked this pull request as ready for review October 24, 2025 13:39
@christian-kreuzberger-dtx christian-kreuzberger-dtx force-pushed the featch/add-oauth-flow-with-codespaces branch 2 times, most recently from bfe64b3 to 8dcea8a Compare October 24, 2025 13:43
@christian-kreuzberger-dtx christian-kreuzberger-dtx force-pushed the featch/add-oauth-flow-with-codespaces branch from 8dcea8a to f613cc2 Compare October 24, 2025 13:45
Copy link
Collaborator

@MrManny MrManny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spicy!

@MrManny MrManny requested a review from Copilot October 29, 2025 07:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds GitHub Codespaces support for OAuth authentication by automatically detecting when the MCP server is running in Codespaces and using the forwarded URL instead of localhost for OAuth redirects.

Key changes:

  • Created utility functions to detect GitHub Codespaces environment and generate forwarded URLs
  • Updated OAuth redirect server to use forwarded URLs when running in Codespaces
  • Added comprehensive test coverage for the new environment detection utilities

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/environment-detection.ts New utility module providing Codespaces detection and forwarded URL generation
src/utils/environment-detection.test.ts Comprehensive test suite for environment detection utilities
src/authentication/dynatrace-oauth-auth-code-flow.ts Updated OAuth redirect server to use forwarded URLs in Codespaces
src/authentication/dynatrace-oauth-auth-code-flow.test.ts Added tests verifying OAuth redirect behavior in Codespaces and localhost
CHANGELOG.md Documented the OAuth callback URL fix for GitHub Codespaces
Comments suppressed due to low confidence (1)

src/authentication/dynatrace-oauth-auth-code-flow.ts:184

  • The server binds to 'localhost' which will not work in GitHub Codespaces. When running in Codespaces, the server should bind to '0.0.0.0' to accept forwarded connections from the Codespaces proxy. Consider conditionally setting the hostname based on whether running in Codespaces: server.listen(port, forwardedUrl ? '0.0.0.0' : 'localhost', () => {
    server.listen(port, 'localhost', () => {

@christian-kreuzberger-dtx christian-kreuzberger-dtx merged commit c868376 into main Oct 29, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants