unjs / giget

✨ Download templates and git repositories with pleasure!
MIT License
446 stars 37 forks source link

GitLab - 406 Not Acceptable download archive error #97

Closed tebaly closed 8 months ago

tebaly commented 1 year ago

Environment

Whith own registry, not working

Reproduction

Whith own registry, not working

Describe the bug

Whith own registry, not working

Additional context

No response

Logs

No response

professorhaseeb commented 1 year ago
# .env file content
GIGET_AUTH="TOKEN"

Gitlab Personal Access token is used, with proper scope(downloads properly using other HTTP clients)

output for: npm run dev

Nuxi 3.5.3                                                                                                                                                                                                               8:26:57 pm
Nuxt 3.5.3 with Nitro 2.4.1

ERROR  Failed to download https://gitlab.com/GROUP/REPO/-/archive/master.tar.gz: 406 Not Acceptable 

at download (/node_modules/giget/dist/shared/giget.093c29e5.mjs:29:11)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async downloadTemplate (/node_modules/giget/dist/shared/giget.093c29e5.mjs:244:5)
  at async resolveConfig (/node_modules/c12/dist/index.mjs:250:20)
  at async extendConfig (/node_modules/c12/dist/index.mjs:217:21)
  at async loadConfig (/node_modules/c12/dist/index.mjs:159:5)
  at async loadNuxtConfig (/node_modules/@nuxt/kit/dist/index.mjs:2447:18)
  at async Object.invoke (/node_modules/nuxi/dist/chunks/dev.mjs:124:20)
  at async _main (/node_modules/nuxi/dist/cli.mjs:48:20)

mentioned repo is private, in a group.

zola33dsf commented 1 year ago

Hey, I have the same problem, did you find any solutions ? @professorhaseeb

NiMalkin commented 11 months ago

Description

Good evening, guys! I have the same problem and I tried all possible solutions to the problem. This doesn't work.

At the same time, everything works fine via curl and postman. Even the docker authorizes successfully, but the giget (and any node.js apps) cannot execute this request. I also got headers and cookies from successful requests - that doesn't work either.

It seems to me that these may be features of the Gitlab settings. Do you have any ideas @tebaly @professorhaseeb @zola33dsf? I would be very grateful for your advice.

Error with CI/CD

ERROR  Failed to download https://gitlab.DOMAIN.com/GROUP/REPO/-/archive/develop.tar.gz: 406 Not Acceptable
  at download (node_modules/.pnpm/giget@1.1.3/node_modules/giget/dist/index.mjs:30:11)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async downloadTemplate (node_modules/.pnpm/giget@1.1.3/node_modules/giget/dist/index.mjs:252:5)
  at async resolveConfig (node_modules/.pnpm/c12@1.4.2/node_modules/c12/dist/index.mjs:250:20)
  at async extendConfig (node_modules/.pnpm/c12@1.4.2/node_modules/c12/dist/index.mjs:217:21)
  at async loadConfig (node_modules/.pnpm/c12@1.4.2/node_modules/c12/dist/index.mjs:159:5)
  at async loadNuxtConfig (node_modules/.pnpm/@nuxt+kit@3.6.5/node_modules/@nuxt/kit/dist/index.mjs:2483:18)

Success with CURL

  curl --header "Authorization: Bearer TOKEN" "https://gitlab.DOMAIN.com/GROUP/REPO/-/archive/develop.tar.gz" --output ./REPO.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1481k  100 1481k    0     0   476k      0  0:00:03  0:00:03 --:--:--  476k

P.S. By the way, if you have problems with CORS - nitro proxy works great.

andreymart-test commented 9 months ago

I have the same problem, with gitlab. Personal public repository.

  at async loadNuxtConfig (/C:/casino/manager/node_modules/.pnpm/@nuxt+kit@3.8.2_rollup@3.29.4/node_modules/@nuxt/kit/dist/index.mjs:2530:18)
  at async Object.run (/C:/casino/manager/node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/chunks/dev.mjs:172:25)
  at async runCommand$1 (/C:/casino/manager/node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1648:16)
  at async runCommand$1 (/C:/casino/manager/node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1639:11)
  at async runMain$1 (/C:/casino/manager/node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1773:7)

 ERROR  Failed to download https://gitlab.com/myUserName/myRepo/-/archive/master.tar.gz: 406 Not Acceptable     

P.S github repositories work without error under identical conditions


Maybe giget is not sending an additional header on request in the case of gitlab - https://stackoverflow.com/questions/14251851/what-is-406-not-acceptable-response-in-http

andreymart-test commented 9 months ago

After a deep and long research, I found these hotlinking rules on gitlab. https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2 The solution for me was to add to the giget library in the fetch mode: 'same-origin' function. I created a PR to fix this error https://github.com/unjs/giget/pull/123

In my fork giget downloading archive from gitlab works without errors.

pi0 commented 8 months ago

The issue should be fixed with workaround in #123 in latest version. (thanks @andreymart-test ❤️ )