Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gitlab): workaround hotlinking protection (406 Not Acceptable) #123

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
}

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

Check warning on line 95 in src/_utils.ts

View check run for this annotation

Codecov / codecov/patch

src/_utils.ts#L93-L95

Added lines #L93 - L95 were not covered by tests
const res = await fetch(url, {
...options,
headers: normalizeHeaders(options.headers),
Expand Down
1 change: 1 addition & 0 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const gitlab: TemplateProvider = (input, options) => {
subdir: parsed.subdir,
headers: {
authorization: options.auth ? `Bearer ${options.auth}` : undefined,
"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