How to use NodeJS/Browsers native fetch library to download a Gitlab Archive without using the same-origin mode? Receiving Error 406

83 views Asked by At

I've been attempting to download a gitlab archive using the native fetch library shipped with NODE.JS

let url = 'https://gitlab.com/api/v4/projects/21015560/repository/archive.zip'
let options = {
  headers: {
    'private-token': token,
  },
  method: 'get',
}

const resp = await fetch(url, options)

console.log(resp.status) //406

This returns an Error 406, Im guessing due to the hotlinking rules. If i use:

let options = {
  headers: {
    'private-token': token,
  },
  method: 'get',
  mode: 'same-origin'
}

it works fine, but I'm wondering if there are any other settings i could apply to get this to work.

A similar request in other http requesting libraries such as curl don't run into this issue, so it must be specific to how fetch builds the request. I've also looked to see if i could compare the raw requests, but wasn't able to figure out how to pull the raw request data from the fetch object. I know i could use another requesting library, but i would prefer to use the native fetch support if possible.

Any suggestions/ideas?

0

There are 0 answers