Skip to content

Commit

Permalink
Fix Android redirects when it is http, change to https
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdowney committed May 7, 2024
1 parent 1ea6dde commit 5bc88bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/services/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export const getSecureUrl = async (mediaUrl: string) => {
}, finalUrl)
if (redirectResponse?.request?.responseURL) {
finalUrl = redirectResponse.request.responseURL

/*
Sometimes the final redirected URL will begin with http. Change it to https
to avoid "cleartext not allowed" errors on Android.
*/
if (mediaUrl.indexOf('http://') >= 0) {
finalUrl = mediaUrl.replace(/http:\/\//g, 'https://')
}
}
}
} catch (error) {
Expand Down

0 comments on commit 5bc88bb

Please sign in to comment.