Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Coder applications always strips the subpath, even if the application can be configured to handle it #14483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #15231
Emyrk opened this issue Aug 29, 2024 · 5 comments
Labels
need-backend Issues that need backend work

Comments

@Emyrk
Copy link
Member

Emyrk commented Aug 29, 2024

When you configure a coder_app that is path based, Coderd will always strip the subpath from the proxied request.

So when you hit

GET /@Emyrk/workspace.main/apps/code-server/

The app sees the request as:

GET / 

This happens in the code here:

// Determine the real path that was hit. The * URL parameter in Chi will not
// include the leading slash if it was present, so we need to add it back.
chiPath := chi.URLParam(r, "*")
basePath := strings.TrimSuffix(r.URL.Path, chiPath)
if strings.HasSuffix(basePath, "/") {
chiPath = "/" + chiPath
}

It strips the base path from the request, assuming the application behind the proxy does not want this base path.

However

Many applications like VSCode Web support flags like --server-base-path, which allows hosting an application on a subpath. This is required, because all urls made from the app are absolute.

So today, if you do not configure --server-base-path, the app will fail to load resources, since it constructs urls from "/". And if you configure the base path, our proxy strips that, so you get a 404 as you hit / on the app, where it expects /@Emyrk/workspace.main/apps/code-server/

Solution

We should have an option on coder_app to not strip the base path from proxied requests. Some boolean like: url_passthrough to tell the proxy service to not alter the request url in any way.

Some other apps that would require this (off the top of my head)

  • RStudio
  • Jupyter (pretty sure)

Why do this

This will expand support for more path based applications.

Would fix this: coder/modules#288

@Emyrk
Copy link
Member Author

Emyrk commented Aug 29, 2024

@matifali what do you think about this?

@matifali
Copy link
Member

matifali commented Sep 2, 2024

@Emyrk IIRC, it used to work when we carefully set the url formatted correctly.
An example is here:
https://github.com/matifali/coder-templates/blob/41d66213e683d3f2164fa2e421cd4fd217a4124a/deeplearning/main.tf#L123

@Emyrk
Copy link
Member Author

Emyrk commented Sep 3, 2024

@Emyrk IIRC, it used to work when we carefully set the url formatted correctly. An example is here: https://github.com/matifali/coder-templates/blob/41d66213e683d3f2164fa2e421cd4fd217a4124a/deeplearning/main.tf#L123

I was trying something like that, but was not sure if the path was always being prepended to requests correctly. Will need to try it.

@matifali
Copy link
Member

@Emyrk any updates?

@Emyrk
Copy link
Member Author

Emyrk commented Sep 27, 2024

The above technique did not work. We would need a url_passthrough parameter

@matifali matifali removed the feature label Oct 14, 2024
@stirby stirby mentioned this issue Oct 25, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-backend Issues that need backend work
Projects
None yet
Development

No branches or pull requests

2 participants