openvsx: error: CORS request did not succeed
Hi,
VSCodium-1.58.0 is getting an error message when loading the list of extensions from open-vsx.org.
After debugging, I’ve reduced the code used to its minimal form so we can test it in the browser(Firefox is consistent unlike Chrome):
(function() {
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://open-vsx.org/vscode/gallery/extensionquery', true);
xhr.setRequestHeader('X-Market-Client-Id', 'VSCode 1.58.0');
xhr.setRequestHeader('X-Market-User-Id', '27ea627c-eac1-4ae6-92fd-d093b80d1ba5');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Accept', 'application/json;api-version=3.0-preview.1');
xhr.onload = (e) => {
console.log(xhr.response);
};
xhr.send('{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"}],"pageNumber":1,"pageSize":50,"sortBy":4,"sortOrder":0}],"assetTypes":[],"flags":950}');
})();
I’m getting:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://open-vsx.org/vscode/gallery/extensionquery. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://open-vsx.org/vscode/gallery/extensionquery. (Reason: CORS request did not succeed).
If you change the url to https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery, there is no more errors.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 46
- Comments: 90 (10 by maintainers)
Commits related to this issue
- Explicitly instruct Spring to allow any origin for API points expected to be used by vscode. Fixes #306 — committed to zoidbb/openvsx by zoidbb 3 years ago
- Merge pull request #319 from berzoidberg/issues/306 #306 Send CORS headers so vscode can use the API — committed to eclipse/openvsx by spoenemann 3 years ago
@SpacingBat3 thanks for the feedback
For the
--disable-web-securityflag, since to disable the security for the whole IDE (including the extensions) is a little over the top, I’m against to make it the default.It’s a server’s configuration issue and from the client standpoint, the main components haven’t much changed from
1.57.1to1.58.0:Some unforeseen circumstances have delayed us from fixing this, but please be aware that it is the number 1 priority for us with Open VSX now and will proceed from there.
Code - OSS (that VS Code but compiled from source thing) doesn’t work, though. Here’s my product.json:
{ "nameShort": "Code - OSS", "nameLong": "Code - OSS", "applicationName": "code-oss", "dataFolderName": ".vscode-oss", "win32MutexName": "vscodeoss", "licenseName": "MIT", "licenseUrl": "https://github.com/microsoft/vscode/blob/main/LICENSE.txt", "win32DirName": "Microsoft Code OSS", "win32NameVersion": "Microsoft Code OSS", "win32RegValueName": "CodeOSS", "win32AppId": "{{E34003BB-9E10-4501-8C11-BE3FAA83F23F}", "win32x64AppId": "{{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}", "win32arm64AppId": "{{D1ACE434-89C5-48D1-88D3-E2991DF85475}", "win32UserAppId": "{{C6065F05-9603-4FC4-8101-B9781A25D88E}", "win32x64UserAppId": "{{CC6B787D-37A0-49E8-AE24-8559A032BE0C}", "win32arm64UserAppId": "{{3AEBF0C8-F733-4AD4-BADE-FDB816D53D7B}", "win32AppUserModelId": "Microsoft.CodeOSS", "win32ShellNameShort": "C&ode - OSS", "darwinBundleIdentifier": "com.visualstudio.code.oss", "linuxIconName": "com.visualstudio.code.oss", "licenseFileName": "LICENSE.txt", "reportIssueUrl": "https://github.com/microsoft/vscode/issues/new", "urlProtocol": "code-oss", "webviewContentExternalBaseUrlTemplate": "https://{{uuid}}.vscode-webview.net/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/", "extensionAllowedProposedApi": ["ms-vscode.vscode-js-profile-flame", "ms-vscode.vscode-js-profile-table", "ms-vscode.remotehub", "ms-vscode.remotehub-insiders", "GitHub.remotehub", "GitHub.remotehub-insiders"], "extensionsGallery": { "serviceUrl": "https://open-vsx.org/vscode/gallery", "itemUrl": "https://open-vsx.org/vscode/item" }, "linkProtectionTrustedDomains": ["https://open-vsx.org"], "builtInExtensions": [{ "name": "ms-vscode.node-debug", "version": "1.44.32", "repo": "https://github.com/microsoft/vscode-node-debug", "metadata": { "id": "b6ded8fb-a0a0-4c1c-acbd-ab2a3bc995a6", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }, { "name": "ms-vscode.node-debug2", "version": "1.42.10", "repo": "https://github.com/microsoft/vscode-node-debug2", "metadata": { "id": "36d19e17-7569-4841-a001-947eb18602b2", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }, { "name": "ms-vscode.references-view", "version": "0.0.80", "repo": "https://github.com/microsoft/vscode-references-view", "metadata": { "id": "dc489f46-520d-4556-ae85-1f9eab3c412d", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }, { "name": "ms-vscode.js-debug-companion", "version": "1.0.14", "repo": "https://github.com/microsoft/vscode-js-debug-companion", "metadata": { "id": "99cb0b7f-7354-4278-b8da-6cc79972169d", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }, { "name": "ms-vscode.js-debug", "version": "1.59.0", "repo": "https://github.com/microsoft/vscode-js-debug", "metadata": { "id": "25629058-ddac-4e17-abba-74678e126c5d", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }, { "name": "ms-vscode.vscode-js-profile-table", "version": "0.0.18", "repo": "https://github.com/microsoft/vscode-js-profile-visualizer", "metadata": { "id": "7e52b41b-71ad-457b-ab7e-0620f1fc4feb", "publisherId": { "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee", "publisherName": "ms-vscode", "displayName": "Microsoft", "flags": "verified" }, "publisherDisplayName": "Microsoft" } }], "date": "2021-08-09T15:10:39.340Z", "checksums": { "vs/base/parts/sandbox/electron-browser/preload.js": "HFNGobD8qQbCdCfqvVVY5A", "vs/workbench/workbench.desktop.main.js": "yQiZWsDlSkAgsBTKQU1cgw", "vs/workbench/workbench.desktop.main.css": "KMkDvr7qWs/pxY6PFMTJYg", "vs/workbench/services/extensions/node/extensionHostProcess.js": "HbpthGdCn6UF8/uWKqSh6A", "vs/code/electron-browser/workbench/workbench.html": "oUELX9mVAjhdP0ND63vLsA", "vs/code/electron-browser/workbench/workbench.js": "TVGTgn9CDp2PQsoXUHdEsQ" } }VSCodium-v1.59.xwill include a patch to disable the CORS validation (which was added in1.58.0).@brianking @spoenemann is there any update to this critical/fundamental issue?
The issue affects all eclipse-theia based cloud applications, vscodium, gitpod and potentially other vscode compatible applications. I attempted a fix for the issue in the past (https://github.com/eclipse/openvsx/pull/292) and I believe the spring endpoints are properly configured. Someone with a greater understanding of the infrastructure (and possibly nginx, proxy) should likely take a look at what the root cause might be.
cc @marcdumais-work @paul-marechal
Call me crazy, but shouldn’t this be fixed already? Shouldn’t take long, and the issue is on the openvsx side (they dont have CORS headers properly set up). CORS is not mysterious.
I’ve found the change: https://github.com/microsoft/vscode/blob/1.58.0/src/main.js#L177 There is a work around but that option will be removed next month.
Hopefully,
open-vsx.orgwill fully support CORS by then@eclipsewebmaster here’s a Bash command that inspects headers for the public instance of Open VSX:
As long as
grepdoesn’t returnAccess-Control-Allow-Origin: *the problem is not fixed.edit: Hopefully this helped you enough despite being wrong… edit: Fixed case sensitivity as the server responds with lowercased
access-control-allow-origin:. edit: Added a placeholderOrigin:header.Please do something about this issue. It has effectively rendered the marketplace in open-source builds of VSCode unusable. If the whole “open marketplace” experiment does not work out, users will have no choice but to go back to proprietary builds of VSCode.
@ocelotsloth VSCodium is disabling the CORS check until OpenVSX fully support them. The Spring component is fully generating the CORS headers but they are dropped by their front-end servers.
Seems to work now, see https://github.com/EclipseFdn/open-vsx.org/issues/633
Can we step the timeline up? This is a pretty fundamental problem for application users.
I’m unable to check for extension upgrades in version
1.58.0-1of the archlinuxcodepackage, which (to the best of my knowledge) uses openvsx.Here’s the error message in the developer tools:
The error message makes me think some important header is missing in the response from open-vsx.org, which is why I came here instead of the archlinux bugtracker.
@eclipsewebmaster I expected the server to respond with
*no matter what so I also missed theOriginheader… This is my bad.Testing now from different origins seems to work fine: the
Acces-Control-Allow-Origin:field copies what was passed asOrigin:which gets rid of the CORS issues!According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin#directives the
*directive is useful for requests made without credentials. Depending on how the API is meant to be accessed the current behavior of copying the declaredOrigin:might be fine? Just not sure what’s the best course of action here.edit: Testing now I see that without an
Originheaderaccess-control-allow-origin: *is returned.@eclipsewebmaster yes, that’s normal.
Everything looks to be working in my vscode install. 😃
Since
VSCode v1.60, this issue has become a catastrophic issue. The path to load the resources with node has been completely removed. So no easy patch. I’ve put on holdVSCodium v1.60until a complete fix of the issue.Thanks! Installing CORS Ublock fixed it for me on Mac.
@madupuis90 Here at https://github.com/VSCodium/vscodium/issues/746#issuecomment-881049046
Seems like something have been changed from client side to validate the CORS policy. I will check that.
If I have time, I will check how to configure CORS with Spring. It’s been years that I haven’t any Java dev and much more with Spring…