microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.42k stars 28.62k forks source link

Port is being added twice to Microsoft dev tunnel in VsCode with absolute URLs #212696

Open a0m0rajab opened 4 months ago

a0m0rajab commented 4 months ago

Does this issue occur when all extensions are disabled?: Yes/No

I am working with the NextJs framework, where I have a link that redirect the users to it in my App. The link works well with the local machine, yet when I use the de tunnel, it adds the port twice to the URL, and it does not work.

Here is my JS code:

 function redirectToLogin(locale: string) {
    return NextResponse.redirect(
      new URL(`/${locale}/login`, hostURL)
    );
  }

Here is the result that I got from the dev tunnels:

https://k630pqpg-3000.euw.devtunnels.ms:3000/tr/login

Here is what I expect:

Either

https://k630pqpg-3000.euw.devtunnels.ms/tr/login

Or

https://k630pqpg.euw.devtunnels.ms:3000/tr/login

My workaround to solve this was to modify the URL by hand, yet it would be great to fix this bug or know a permanent solution. (thanks to this issue for getting the workaround (https://github.com/microsoft/vscode/issues/190020))

Is there a way to define the URL that I got from the dev tunnels? or fix that duplicate port issue?

### Tasks
alexr00 commented 4 months ago

Here is the result that I got from the dev tunnels

How are you getting this? From the Ports view?

a0m0rajab commented 4 months ago

Nope, I from the port view I am getting the correct results, yet when I open the app it redirects me to the link I mentioned. In the JS code I provided the hostURL is localhost:300

alexr00 commented 4 months ago

I'm still having trouble understanding. Could you make a screen capture to show this?

a0m0rajab commented 4 months ago

Hi, thanks for following up; I just made a minimum working code in this repo: https://github.com/a0m0rajab/ms-tunnels-error, which has a minimal reproducible code to test.

Here is a video recording of the issue:

https://github.com/microsoft/vscode/assets/18273833/b16a4c7a-28ad-4155-b9a3-ea4c7e43c556

test 1 -> The link: http://localhost:3000/test1 expected to work well. there is no redirect 404 is normal

Test 2 -> The link: http://localhost:3000/test2 expected : https://randoms-3000.euw.devtunnels.ms/login got: https://randoms-80.euw.devtunnels.ms/login

Test 3 -> The link: http://localhost:3000/test3 expected: https://randoms-3000.euw.devtunnels.ms/login got: https://randoms-3000.euw.devtunnels.ms:3000/login

alexr00 commented 3 months ago

Thanks for the recording! So, you are opening VS Code, connecting to another machine using dev tunnels, then following the steps in https://github.com/a0m0rajab/ms-tunnels-error?tab=readme-ov-file#getting-started from the VS Code integrated terminal?

a0m0rajab commented 3 months ago

Yes that's exactly what I am doing

a0m0rajab commented 3 months ago

Hi @alexr00 any update on this?

alexr00 commented 2 months ago

@connor4312 I think this is coming from the dev tunnels extension.

a0m0rajab commented 2 months ago

@alexr00 thanks for the comment,. @connor4312 if the extension is open source would you like to point to it's code, I would love to take a look at it and see if I can debug this.

connor4312 commented 2 months ago

Sure, that's https://github.com/microsoft/vscode/tree/main/extensions/tunnel-forwarding.