Skip to content

Commit 257a7dd

Browse files
committed
fix: Upload release failed. Response status: 401 Unauthorized
Close #1385
1 parent a3c4a9e commit 257a7dd

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

docs/Auto Update.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do
328328

329329
| Name | Type | Description |
330330
| --- | --- | --- |
331-
| autoDownload = <code>true</code>| <code>boolean</code> | <a name="AppUpdater-autoDownload"></a>Automatically download an update when it is found. |
331+
| autoDownload = <code>true</code>| <code>boolean</code> | <a name="AppUpdater-autoDownload"></a>Whether to automatically download an update when it is found. |
332+
| allowPrerelease| <code>boolean</code> | <a name="AppUpdater-allowPrerelease"></a>*GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.<br><br>If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). |
333+
| allowDowngrade| <code>boolean</code> | <a name="AppUpdater-allowDowngrade"></a>Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`. |
332334
| requestHeaders| <code>[RequestHeaders](electron-builder-http#RequestHeaders)</code> \| <code>null</code> | <a name="AppUpdater-requestHeaders"></a>The request headers. |
333335
| logger = <code>(&lt;any&gt;global).__test_app ? null : console</code>| <code>[Logger](#Logger)</code> \| <code>null</code> | <a name="AppUpdater-logger"></a>The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`. Set it to `null` if you would like to disable a logging feature. |
334336
| signals = <code>new UpdaterSignal(this)</code>| <code>[UpdaterSignal](#UpdaterSignal)</code> | <a name="AppUpdater-signals"></a>For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})` |

packages/electron-builder-http/src/httpExecutor.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export abstract class HttpExecutor<REQUEST_OPTS, REQUEST> {
110110
}
111111

112112
const newUrl = parseUrl(redirectUrl)
113-
this.doApiRequest(<REQUEST_OPTS>removeAuthHeader(Object.assign({}, options, newUrl)), cancellationToken, requestProcessor, redirectCount)
113+
this.doApiRequest(<REQUEST_OPTS>Object.assign({}, options, newUrl), cancellationToken, requestProcessor, redirectCount)
114114
.then(resolve)
115115
.catch(reject)
116116
return
@@ -161,11 +161,11 @@ export abstract class HttpExecutor<REQUEST_OPTS, REQUEST> {
161161
if (redirectUrl != null) {
162162
if (redirectCount < this.maxRedirects) {
163163
const parsedUrl = parseUrl(redirectUrl)
164-
this.doDownload(removeAuthHeader(Object.assign({}, requestOptions, {
164+
this.doDownload(Object.assign({}, requestOptions, {
165165
hostname: parsedUrl.hostname,
166166
path: parsedUrl.path,
167167
port: parsedUrl.port == null ? undefined : parsedUrl.port
168-
})), destination, redirectCount++, options, callback, onCancel)
168+
}), destination, redirectCount++, options, callback, onCancel)
169169
}
170170
else {
171171
callback(new Error(`Too many redirects (> ${this.maxRedirects})`))
@@ -310,14 +310,4 @@ export function dumpRequestOptions(options: RequestOptions): string {
310310
safe.headers.authorization = "<skipped>"
311311
}
312312
return JSON.stringify(safe, null, 2)
313-
}
314-
315-
// requestOptions should be cloned already, modified in place
316-
function removeAuthHeader(requestOptions: RequestOptions): RequestOptions {
317-
// github redirect to amazon s3 - avoid error "Only one auth mechanism allowed"
318-
if (requestOptions.headers != null && (requestOptions.hostname || "").includes(".amazonaws.") && requestOptions.headers.Authorization != null && requestOptions.headers.Authorization.startsWith("token ")) {
319-
requestOptions.headers = Object.assign({}, requestOptions.headers)
320-
delete requestOptions.headers.Authorization
321-
}
322-
return requestOptions
323313
}

0 commit comments

Comments
 (0)