Skip to content

Commit

Permalink
fix: add User-Agent header to bypass API check
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Oct 29, 2023
1 parent 42c08e4 commit 76f6364
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api/[owner]/[app]/[version].ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export interface DownloadInfo {

const NOT_FOUND = 404

const FETCH_OPTIONS = {
headers: {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
},
}

export const config = {
runtime: 'edge',
}
Expand All @@ -32,7 +39,7 @@ export default async (req: Request): Promise<Response> => {

console.log(`Fetching ${releasesUrl}`)

const releasesRes = await fetch(releasesUrl)
const releasesRes = await fetch(releasesUrl, FETCH_OPTIONS)
const releases = (await releasesRes.json()) as ReleaseInfo[]

const matched = releases.find(
Expand All @@ -52,7 +59,7 @@ export default async (req: Request): Promise<Response> => {

console.log(`Fetching ${releaseUrl}`)

const downloadInfoRes = await fetch(releaseUrl)
const downloadInfoRes = await fetch(releaseUrl, FETCH_OPTIONS)
const { download_url: downloadUrl } =
(await downloadInfoRes.json()) as DownloadInfo

Expand Down

0 comments on commit 76f6364

Please sign in to comment.