azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.45k stars 119 forks source link

[BUG]: URLs: Path Prefix not working (f.e. with Code-Server) #320

Closed madejackson closed 1 week ago

madejackson commented 3 weeks ago

What happened?

When I try to use a Path Prefix for Code-Server, it doesn't work.

What should have happened?

Code-Server supports sub-paths via proxy and does not need any config for that, it should just work. some Sources: https://github.com/coder/code-server/issues/1987 https://github.com/coder/code-server/issues/241 https://github.com/coder/code-server/discussions/1739

How to reproduce the bug?

  1. Install Code Server
  2. go To URLs -> Code Server -> Setup
  3. enable "Use Path Prefix", add Path Prefix f.e. /code
  4. Save, Test

Relevant log output

No response

Other details

tested with 0.15.7 and 0.16.0-unstable27

System details

azukaar commented 3 weeks ago

You need the "Strip Path Prefix" to be on, but it seems this option has broken I am assuming this happened when I hardened the API routes 2 releases ago need to take a look

madejackson commented 3 weeks ago

Yeah I forgot to mention I tried with and without stripping and different paths, also "existing" ones on the app like /?folder= or /?folder=/ without path stripping. This did not work neither, though could be a different issue.

madejackson commented 2 weeks ago

@azukaar

Short Update to this, it's definitely more broken than only strip path prefix. Issue is the same with filebrowser with /filebrowser as subpath configured (so no pathstrip).

Also another Issue with URL's: Custom CORS Origin seems to be ignored. Disable Header Hardening disables CORS though no matter the settings in Custom CORS Origin.

I can reproduce all of this in 0.15.7 and 0.16.0-beta.

azukaar commented 1 week ago

I looked at it, the issue comes from code-server itself and generally speaking how path-based routing work (and why I designed Cosmos to highly discourage using this option, such as not having a "path" option in the market). Long story short, path based routing works as expected in Cosmos. I can create a route to code server that goes to /code-server and shows the app.

The issues you are seeing are:

This kind of issues is why I just want people to use either ip:port, subdomains, or the newly added .local domains system. Base path DO NOT WORK with most apps, and there's nothing anyone can do about it except the dev of each apps who can add support for it.

image