-
Notifications
You must be signed in to change notification settings - Fork 0
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
VS Code sends OPTIONS -- not handled by a redirect #6
Comments
I think the OPTIONS request is a CORS pre-flight check that occurs when this extension sends an XMLHttpRequest GET request with an Authorization header to https://hsdev.bidmc.org/terminal-vscode/ from its webview. Instead of your Apache responding to this OPTIONS request with a 302 can it be made to return a 204 No Content with the following headers? Access-Control-Allow-Credentials: true I'm not familiar enough with Apache modules to know how/if the incoming Origin header can be returned as the value of Access-Control-Allow-Origin. Nor am I certain the above will solve your issue, as it's based on my theoretical understanding rather than testing. I don't fully understand why you need to do that redirect of /terminal-vscode/ to /terminal-vscode/index. Do you also have to do the equivalent for /terminal/ to make that work from a browser? |
@gjsjohnmurray thanks per usual timely and insightful reply. Yes, /terminal/ and /terminal-vscode/ work from a browser as advertised. I did not know about holding ALT-click in VS Code will launch the desired URL in an external browser -- that works, so there's a viable workaround here, very cool. I tried setting the OPTIONS response in Apache as advised, no joy launching a terminal embedded within VS Code:
We will start with the ALT-click method, thank you. But because you asked and probably too much information posted here, the Apache service redirect is because we do not want by default for Apache to pass "everything" with an alias "/" to the CSP handler. We use a very layered httpd conf.d file layout for the variety of host needs to serve up static & dynamic content, run scripts, proxy to Node & Python services, etc. For Caché & IRIS, we make explicit aliases to pass to their CSP handler within any VirtualHost ServerName needing it, i.e., hsdev.bidmc.org:
The problem I see from this within %CSP.REST is that the Routes fail on a "naked" endpoint such as /terminal/ and /terminal-vscode/. This approach acts as if the endpoint result is empty "", even if I change the "/" RegExp to optional "/?":
Commenting out all of the /terminal-vscode/ above results in this:
... and commenting out /terminal/ redirect results in this:
... whereas appending index works:
|
Something I read said that |
I may be mistaken, but I don't believe we're having any CORS handling issues. OPTIONS gets consumed regardless, whether by Apache (without trail /) or by the WebTerminal.cls (required trailing /) and sameSite=none:
So I made this Apache service send everything "/" to CSP, so no redirects are imposed. CLI curl and incognito Browser tests all worked as expected. But from VS Code, that same OPTIONS URL is returning a 500 internal server error:
Changing Allow Origin to https://bidmc.org and with https://bidmc.harvard.edu made no difference:
|
When WebTerminal is being launched in a tab inside VS Code it is hosted by a webview. It's this architecture that makes me think that the OPTIONS requests your web server is logging when you're launching this way is a CORS preflight request. Are you able to record more details of these requests, perhaps by using the InterSystems Web Gateway's trace facilities? |
@theflyingape I am doing some housekeeping. Are you still using this extension? |
From a browser, https://server/terminal/ and https://server/terminal-vscode/ work as advertised, thank you.
But using it from VS Code does not, because we have to have our Apache server redirect /terminal-vscode/ to /terminal-vscode/index (because Route "/" is never called unless we redirect ALL "/" to CSP -- not happening). The result from VS Code is:
10.15.13.115 - - [17/Oct/2022:21:19:47 -0400] "OPTIONS /terminal-vscode/ HTTP/1.1" 302 229 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.72.2 Chrome/102.0.5005.167 Electron/19.0.17 Safari/537.36"
So a gratuitous OPTIONS is called, appropriately handled by the server, but not the client.
The text was updated successfully, but these errors were encountered: