From ca3edcae433bd5539805cd9ad5bc4acf33a9b8c6 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Wed, 17 Jan 2024 15:58:49 +0100 Subject: [PATCH] feat: proxy theme request --- .vitepress/update-theme.mjs | 2 +- functions/__/vitepress-theme.tgz.ts | 12 ++++++++++++ package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 functions/__/vitepress-theme.tgz.ts diff --git a/.vitepress/update-theme.mjs b/.vitepress/update-theme.mjs index f11b7427..6e890315 100644 --- a/.vitepress/update-theme.mjs +++ b/.vitepress/update-theme.mjs @@ -1,6 +1,6 @@ import { execSync } from 'child_process' -const THEME_URL = `https://github.com/NativeScript/docs/releases/download/vitepress-theme/vitepress-theme.tgz` +const THEME_URL = `https://docs.nativescript.org/__/vitepress-theme.tgz` execSync('yarn remove @nativescript/vitepress-theme') execSync(`yarn add -D ${THEME_URL}?${Date.now()}`) diff --git a/functions/__/vitepress-theme.tgz.ts b/functions/__/vitepress-theme.tgz.ts new file mode 100644 index 00000000..5d06d438 --- /dev/null +++ b/functions/__/vitepress-theme.tgz.ts @@ -0,0 +1,12 @@ +export async function onRequest(context) { + let response = await fetch( + 'https://github.com/NativeScript/docs/releases/download/vitepress-theme/vitepress-theme.tgz' + ) + response = new Response(response.body, response) + + // Set CORS headers + response.headers.set('Access-Control-Allow-Origin', '*') + response.headers.set('Access-Control-Allow-Methods', 'GET, OPTIONS') + + return response +} diff --git a/package.json b/package.json index 979df624..c433e25e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "update-theme": "node ./.vitepress/update-theme.mjs" }, "devDependencies": { - "@nativescript/vitepress-theme": "https://github.com/NativeScript/docs/releases/download/vitepress-theme/vitepress-theme.tgz?1696967568385", + "@nativescript/vitepress-theme": "https://docs.nativescript.org/__/vitepress-theme.tgz?1696967568385", "@types/node": "18.11.9", "npm-run-all": "^4.1.5", "prettier": "^2.7.1",