stackblitz / core

Online IDE powered by Visual Studio Code ⚡️
https://stackblitz.com
MIT License
10.31k stars 919 forks source link

Unable to fetch Nuxt layer GitHub dependencies in Codeflow (CORS error) #3077

Closed MexicanAce closed 3 months ago

MexicanAce commented 5 months ago

Description of Bug

The zksync-docs repo uses Nuxt Layers, and more specifically references other public GitHub repos (see nuxt.config.ts file here). When opening the repo in Codeflow, the terminal will fail to run npm install and output the following error:

> npm install
[...]
> zksync-docs@0.0.0 postinstall
> nuxt prepare

[10:36:59 AM]  ERROR  Failed to download https://api.github.com/repos/matter-labs/docs-nuxt-template/tarball/main: TypeError: fetch failed

  at eval (node_modules/giget/dist/index.mjs:78:11)
  at async sendFetch (node_modules/giget/dist/index.mjs:74:15)
  [... rest of stack trace ...]

After further investigation, it looks like this is due to a CORS error:

Access to fetch at 'https://codeload.github.com/matter-labs/docs-nuxt-template/legacy.tar.gz/refs/heads/main' (redirected from 'https://api.github.com/repos/matter-labs/docs-nuxt-template/tarball/main') from origin 'https://zksyncdocs-a2ws.w-credentialless-staticblitz.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Steps to Reproduce

  1. Go to https://pr.new/github.com/matter-labs/zksync-docs
  2. Wait for npm install to automatically start and see the fetch failures

Expected Behavior

npm install successfully completes

Screenshots/Screencast

image

samdenty commented 5 months ago

We recently added support for Cors Proxy, which may fix this issue https://blog.stackblitz.com/posts/cors-proxy/. Though because it's coming from NPM, I'm not 100% sure

MexicanAce commented 5 months ago

@samdenty Good to know, I'm trying to use the new flag but I keep getting prompted with the following modal (I've upgraded my account today, so maybe it takes a while to reflect within the IDE?) image

samdenty commented 4 months ago

Cc @d3lm @Nemikolh

MexicanAce commented 4 months ago

It's been over a week after I've upgraded my account, and I still get this popup. So doesn't look like an issue related to timing.

kirjavascript commented 4 months ago

It's been over a week after I've upgraded my account, and I still get this popup. So doesn't look like an issue related to timing.

hi! We've looked into the issue and in the process of fixing it uncovered some other issues related to it. Once they are resolved we can deploy the fix.

It should be resolved soon!

MexicanAce commented 4 months ago

Hi @kirjavascript 👋 , any update on a fix?

samdenty commented 4 months ago

Hi @MexicanAce we have a fix merged but it's not deployed yet, i'll see to it that it's deployed now

kirjavascript commented 3 months ago

sorry for the delay, but the fix should be deployed now!