client/web: enforce full path for CGI platforms

Synology and QNAP both run the web client as a CGI script. The old web
client didn't care too much about requests paths, since there was only a
single GET and POST handler. The new client serves assets on different
paths, so now we need to care.

First, enforce that the CGI script is always accessed from its full
path, including a trailing slash (e.g. /cgi-bin/tailscale/index.cgi/).
Then, strip that prefix off before passing the request along to the main
serve handler. This allows for properly serving both static files and
the API handler in a CGI environment. Also add a CGIPath option to allow
other CGI environments to specify a custom path.

Finally, update vite and one "api/data" call to no longer assume that we
are always serving at the root path of "/".

Updates tailscale/corp#13775

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-08-24 12:56:09 -07:00
committed by Will Norris
parent 0c3d343ea3
commit dc8287ab3b
5 changed files with 44 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ filteringLogger.info = (...args) => {
// https://vitejs.dev/config/
export default defineConfig({
base: "/",
base: "./",
plugins: [
paths(),
svgr(),