Closed jamesaoverton closed 2 years ago
FYI here is what the CGI spec says:
SCRIPT_NAME
A URL path that could identify the CGI script (rather then the
particular CGI output). The syntax and semantics are identical to
a decoded HTTP URL `hpath' token [[4](https://datatracker.ietf.org/doc/html/draft-robinson-www-interface-00#ref-4)].
SCRIPT_NAME = "" | "/" [ path ]
The leading "/" is not part of the path. It is optional if the
path is NULL.
The SCRIPT_NAME string is some leading part of the <path>
component of the script URI derived in some implementation defined
manner.
This doesn't seem inconsistent with the way that you are proposing to use it, agreed?
The reason that Flask redirects, if you do not override SCRIPT_PATH, to the weird URL mentioned above which includes the script's absolute path, is because DROID is adding the absolute path.
It shouldn't be difficult to set it to the URL path (in the above example: https://droid.ontodev.com/ODD/branches/fix-1/views/test.py)
Currently when running a Flask app under CGI, we need to override the
SCRIPT_NAME
before calling theCGIHandler
, like so:https://github.com/ontodev/nanobot/blob/main/nanobot/run.py#L1823
If we do not, Flask will redirect to a weird URL that includes the absolute script path, such as https://droid.ontodev.com/var/www/droid.ontodev.com/projects/ODD/workspace/fix-1/test.py/?project-name=ODD&branch-name=fix-1&view-path=test.py when we want https://droid.ontodev.com/ODD/branches/fix-1/views/test.py
As in #123 we should consult the CGI spec, but this seems harmless.