8000 Coder applications always strips the subpath, even if the application can be configured to handle it · Issue #14483 · coder/coder · GitHub
[go: up one dir, main page]

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

Description

@Emyrk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-backendIssues that need backend work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0