Open alexvy86 opened 5 years ago
I am not sure why our server URL detection code replaces the host name with 'localhost'. But it sounds fixable.
In the mean time, in case you are not aware, you can configure how we start the browser (or remove it all together and launch the browser manually).
Yes, for now my workaround was to set the URL manually in launch.json
.
I'm curious, how is auto-detect-url
determined? I read in the discussion for another issue that you wait for a particular message in the application's stdout to know when the web server is running, so at first I thought you simply grabbed the URL where the web server says it is listening, but as you can see in the logs above, that one (https://[::]:4430
) doesn't exactly match the one that the browser gets (https://localhost:4430
).
In any case, I'm pretty sure it's the kestrel endpoint URL that is being used as a base and not applicationUrl
because only when i change the port of the kestrel endpoint, do I se the corresponding change when launching the browser. applicationUrl
seems to be left unused... But I imagine that's the value you'd want to use, to match the VS experience?
@alexvy86 Can you provide more detail on how you set the URL manually in launch.json
? I'm experiencing the same issue here
@karl-roberts I've been away from the project that triggered this so I might be misremembering something, and maybe you already figured it out, but I think this is what you'd need, specifically the launchBrowser.args
part (or the OS-specific variants).
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/my-app.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "https://url-you-want-to-launch",
"windows": {
"command": "cmd.exe",
"args": "/C start https://url-you-want-to-launch"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
}
,]
}
Issue Description
I'm using Kestrel for local development. During a debugging session, the URL that's being passed to the browser (with
${auto-detect-url}
inlaunch.json
) is always based on one of the endpoints configured for Kestrel, and is always usinglocalhost
as the hostname. E.g. if my Kestrel configuration looks like this:The URL that's passed to the browser seems to be the one from the Kestrel endpoint, with
my.domain.local
replaced withlocalhost
. I believe that's how Kestrel ends up using them for its purposes (it only cares about the port it needs to bind to), but for debugging purposes, I actually want to browse tohttps://my.domain.local:4430
instead ofhttps://localhost:4430
, since my SSL cert is for the former. I know there's a dev cert for localhost, but in my use case the hostname matters to the application, so I can't use a URL with localhost in it.Now, my
launchSettings.json
file looks like this:Visual Studio uses the value of
applicationUrl
when it starts the browser after I hit F5, but VS Code doesn't, and I think it'd be good to match the behavior. Furthermore, it seems like the only option to launch the browser with a non-localhost URL.Steps to Reproduce
In any project, set
applicationUrl
inlaunchSettings.json
to a non-localhost URL, and start a debugging session in VS Code.Expected Behavior
The browser navigates to the URL specified in
applicationUrl
.Actual Behavior
The browser navigates to a URL that matches one of the endpoints configured for Kestrel, always using
localhost
instead of whatever URL was written in the Kestrel endpoint configuration.Logs
A bit of relevant log from the debugging session:
OmniSharp log
C# log
Empty
Environment information
VSCode version: 1.31.1 C# Extension: 1.17.1
Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.2.101 Commit: 236713b0b7 Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.101\ Host (useful for support): Version: 2.2.0 Commit: 1249f08fed .NET Core SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.402 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk] 2.1.500 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.600-preview-009426 [C:\Program Files\dotnet\sdk] 2.1.600-preview-009472 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |application-insights|VisualStudioOnlineApplicationInsights|0.4.2| |azure-account|ms-vscode|0.8.0| |azurecli|ms-vscode|0.4.2| |azurerm-vscode-tools|msazurermtools|0.4.2| |bower|donjayamanne|0.0.3| |csharp|ms-vscode|1.17.1| |debugger-for-chrome|msjsdiag|4.11.2| |docker-explorer|formulahendry|0.1.6| |dotenv|mikestead|1.0.1| |EditorConfig|EditorConfig|0.13.0| |githistory|donjayamanne|0.4.6| |gitignore|codezombiech|0.6.0| |gitlens|eamodio|9.5.1| |LiveServer|ritwickdey|5.5.1| |material-icon-theme|PKief|3.6.3| |mssql|ms-mssql|1.4.0| |PowerShell|ms-vscode|1.11.0| |python|ms-python|2019.1.0| |rest-client|humao|0.21.1| |theme-dracula|dracula-theme|2.16.0| |vscode-azureappservice|ms-azuretools|0.12.0| |vscode-azurefunctions|ms-azuretools|0.14.0| |vscode-docker|PeterJausovec|0.5.2| |vscode-eslint|dbaeumer|1.8.0| |vscode-markdownlint|DavidAnson|0.24.0| |vscode-nginx|shanoor|0.6.0| |vscode-proto3|zxh404|0.2.2| |vscode-pull-request-github|GitHub|0.4.0| |vscode-yaml|redhat|0.3.0| |vsliveshare|ms-vsliveshare|0.3.1225| |xml|DotJoshJohnson|2.4.0|;