core: use npms cdn endpoint to avoid going through server.

This commit is contained in:
Koushik Dutta
2022-01-10 13:38:56 -08:00
parent fd9556bc8b
commit 84432db7f9
5 changed files with 12 additions and 19 deletions

View File

@@ -100,7 +100,7 @@ export default {
doSearch: debounce(function () {
axios
.get(
`${getComponentWebPath("script")}/search?text=keywords:scrypted+${
`https://registry.npmjs.org/-/v1/search?text=keywords:scrypted+${
this.search
}`
)

View File

@@ -10,7 +10,12 @@ export interface PluginUpdateCheck {
}
export async function checkUpdate(npmPackage: string, npmPackageVersion: string): Promise<PluginUpdateCheck> {
const response = await axios.get(`${componentPath}/npm/${npmPackage}`);
// const response = await axios.get(`${componentPath}/npm/${npmPackage}`);
// registry.npmjs.org does not support CORS on the package endpoints.
// open issue:
// https://github.com/npm/feedback/discussions/117
// npmjs.cf is an unofficial CDN that provides it
const response = await axios.get(`https://registry.npmjs.cf/${npmPackage}`);
const { data } = response;
const versions = Object.values(data.versions).sort((a: any, b: any) => semver.compare(a.version, b.version)).reverse();
let updateAvailable: any;