Github Codespaces + Dotnet - Port forwarding and urls work but not really

130 views Asked by At

I have a dotnet application on github codespaces. The end result is that when launched, the browser is opened to the URL:

https://[redacted]-8081.app.github.dev:8081

This includes -8081 in the subdomain and does not include the path /graphql I defined on .vscode/launch.json. This matches the URL on the Ports -> Forwarded Address which shows the running process for it. Resulting on a 404, even if I add the /graphql.

The application works/responds correctly (no -8081, added /graphql) on:

https://[redacted].app.github.dev:8081/graphql/

Questions being:

  • How do I make vscode append /graphql to the path when launching the browser?
  • Either
    • How do I make the application work on the subdomain including -8081?
    • How do I make vscode / devcontainer understand that the subdomain should not contain -8081?

Relevant parts of devcontainer.json

{
    "forwardPorts": [
        8081
    ],
    "portsAttributes": {
        "8081": {
            "protocol": "https",
            "visibility": "private",
            "onAutoForward": "notify"
        }
    }
}

Relevant parts of .vscode/launch.json

{
    "name": "C#: ASPNetCoreWebAPI Debug",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build backend",
    "program": "${workspaceFolder}/ASPNETCoreWebAPI/bin/Debug/net8.0/ASPNETCoreWebAPI.dll",
    "cwd": "${workspaceFolder}/ASPNETCoreWebAPI",
    "serverReadyAction": {
        "action": "openExternally",
        "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
        "uriFormat": "%s/graphql/"
    }, 
    "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
    }
},

Relevant parts of the project's Properties/launchsettings.json:

"ASPNETCoreWebAPI": {
  "commandName": "Project",
  "launchBrowser": true,
  "launchUrl": "graphql",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "applicationUrl": "https://localhost:8081",
  "dotnetRunMessages": true
},
0

There are 0 answers