Skip to content

Commit

Permalink
fix(gitlab): workaround hotlinking protection (406 Not Acceptable) (#123
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andreymart-test committed Dec 23, 2023
1 parent 1945818 commit 3e58ae6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export async function sendFetch(
}
}

// https://github.com/nodejs/undici/issues/1305
if (options.headers?.["sec-fetch-mode"]) {
options.mode = options.headers["sec-fetch-mode"] as any;
}

const res = await fetch(url, {
...options,
headers: normalizeHeaders(options.headers),
Expand Down
2 changes: 2 additions & 0 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const gitlab: TemplateProvider = (input, options) => {
subdir: parsed.subdir,
headers: {
authorization: options.auth ? `Bearer ${options.auth}` : undefined,
// https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2
"sec-fetch-mode": "same-origin",
},
url: `${gitlab}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
tar: `${gitlab}/${parsed.repo}/-/archive/${parsed.ref}.tar.gz`,
Expand Down

0 comments on commit 3e58ae6

Please sign in to comment.