From 8e5d1092164d15a3392e1e2ac45694d6ced41eef Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Tue, 18 Mar 2025 16:47:25 +0530 Subject: [PATCH 1/2] chore: update proxy URLs to use Ton Studio CDN --- .env.example | 2 -- .github/workflows/deploy.yml | 1 - Dockerfile | 4 +--- .../ProjectTemplate/ProjectTemplate.tsx | 18 ++++-------------- src/config/AppConfig.ts | 4 ++-- src/constant/projectExamples.ts | 5 +++-- src/utility/gitRepoDownloader.ts | 5 ++--- 7 files changed, 12 insertions(+), 27 deletions(-) diff --git a/.env.example b/.env.example index a5476836..2f095518 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,3 @@ RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false NEXT_PUBLIC_DISABLE_WEBCONTAINER=false -# https://proxy.cors.sh/ -NEXT_PUBLIC_PROXY_KEY= diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc1835b4..87ea2d44 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -73,7 +73,6 @@ jobs: sha=${{ github.sha }} sha_short=${{ env.GITHUB_SHA_SHORT }} app_env=${{ env.APP_ENV }} - NEXT_PUBLIC_PROXY_KEY=${{ secrets.NEXT_PUBLIC_PROXY_KEY }} NEXT_PUBLIC_MIXPANEL_TOKEN=${{ secrets.NEXT_PUBLIC_MIXPANEL_TOKEN }} NEXT_PUBLIC_ANALYTICS_ENABLED=${{ secrets.NEXT_PUBLIC_ANALYTICS_ENABLED }} diff --git a/Dockerfile b/Dockerfile index 3e35b247..07c60f43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,12 +5,10 @@ COPY package*.json ./ RUN npm install --ignore-engines COPY . . -ARG NEXT_PUBLIC_PROXY_KEY=redacted_next_public_proxy_key ARG NEXT_PUBLIC_MIXPANEL_TOKEN=redacted_next_public_mixpanel_token ARG NEXT_PUBLIC_ANALYTICS_ENABLED=false -RUN NEXT_PUBLIC_PROXY_KEY=${NEXT_PUBLIC_PROXY_KEY} \ - NEXT_PUBLIC_MIXPANEL_TOKEN=${NEXT_PUBLIC_MIXPANEL_TOKEN} \ +RUN NEXT_PUBLIC_MIXPANEL_TOKEN=${NEXT_PUBLIC_MIXPANEL_TOKEN} \ NEXT_PUBLIC_ANALYTICS_ENABLED=${NEXT_PUBLIC_ANALYTICS_ENABLED} \ npm run build diff --git a/src/components/template/ProjectTemplate/ProjectTemplate.tsx b/src/components/template/ProjectTemplate/ProjectTemplate.tsx index 54398ffe..385ae341 100644 --- a/src/components/template/ProjectTemplate/ProjectTemplate.tsx +++ b/src/components/template/ProjectTemplate/ProjectTemplate.tsx @@ -2,7 +2,6 @@ import { NewProject } from '@/components/project'; import { useTheme } from '@/components/shared/ThemeProvider'; import AppIcon from '@/components/ui/icon'; -import { AppConfig } from '@/config/AppConfig'; import { projectExamples } from '@/constant/projectExamples'; import { App, Drawer, Skeleton } from 'antd'; import axios from 'axios'; @@ -44,22 +43,13 @@ const ProjectTemplate: FC = () => { const getContent = async () => { const link = examples[currentExample].link; - const contractURL = `${AppConfig.proxy.url}${ - projectExamples.baseURL + link + '/contract.tact' - }`; - const contentURL = `${AppConfig.proxy.url}${ - projectExamples.baseURL + link + '/content.md' - }`; + const contractURL = projectExamples.baseURL + link + '/contract.tact'; + const contentURL = projectExamples.baseURL + link + '/content.md'; setContractDetails(contractBlank); try { setLoading('content'); - const axiosParams = { - headers: { - 'x-cors-api-key': AppConfig.proxy.key, - }, - }; - const contractResponse = await axios.get(contractURL, axiosParams); - const contentResponse = await axios.get(contentURL, axiosParams); + const contractResponse = await axios.get(contractURL); + const contentResponse = await axios.get(contentURL); const content = '```ts\n' + contractResponse.data + '\n```\n' + contentResponse.data; diff --git a/src/config/AppConfig.ts b/src/config/AppConfig.ts index ae929604..5a4ccae5 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -10,8 +10,8 @@ export const AppConfig = { IS_ENABLED: !!process.env.NEXT_PUBLIC_ANALYTICS_ENABLED || false, }, proxy: { - key: process.env.NEXT_PUBLIC_PROXY_KEY ?? '', - url: process.env.NEXT_PUBLIC_PROXY_URL ?? 'https://proxy.cors.sh/', + GIT_RAW_CONTENT: 'https://cdn-ide-raw.tonstudio.io', + GIT_IMPORT: 'https://cdn-ide-github.tonstudio.io', }, cors: { proxy: diff --git a/src/constant/projectExamples.ts b/src/constant/projectExamples.ts index ebb4c14b..18f0ff9a 100644 --- a/src/constant/projectExamples.ts +++ b/src/constant/projectExamples.ts @@ -1,6 +1,7 @@ +import { AppConfig } from '@/config/AppConfig'; + export const projectExamples = { - baseURL: - 'https://raw.githubusercontent.com/tact-lang/tact-by-example/main/src/routes/(examples)/', + baseURL: `${AppConfig.proxy.GIT_RAW_CONTENT}/tact-lang/tact-by-example/main/src/routes/(examples)/`, examples: [ { link: '01-the-deployable-trait', diff --git a/src/utility/gitRepoDownloader.ts b/src/utility/gitRepoDownloader.ts index 2555d520..732664d4 100644 --- a/src/utility/gitRepoDownloader.ts +++ b/src/utility/gitRepoDownloader.ts @@ -36,7 +36,7 @@ async function convertToZipUrl( branchName = repoData.default_branch; } - const zipUrl = `https://github.com/${owner}/${repo}/archive/refs/heads/${branchName}.zip`; + const zipUrl = `${owner}/${repo}/archive/refs/heads/${branchName}.zip`; return { url: zipUrl, path: pathName }; } @@ -55,8 +55,7 @@ export async function downloadRepo(repoURL: string): Promise { throw new Error('Invalid GitHub URL'); } - const zipResponse = await axios.get(`${AppConfig.proxy.url}${url}`, { - headers: { 'x-cors-api-key': AppConfig.proxy.key }, + const zipResponse = await axios.get(`${AppConfig.proxy.GIT_IMPORT}/${url}`, { responseType: 'arraybuffer', }); From feaeae82c71a83882331f834b22f3fa9d7c0edd4 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Wed, 23 Apr 2025 13:23:17 +0530 Subject: [PATCH 2/2] chore: update CDN for git import --- src/config/AppConfig.ts | 2 +- src/utility/gitRepoDownloader.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/AppConfig.ts b/src/config/AppConfig.ts index 1f3444a5..13a5604c 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -22,7 +22,7 @@ export const AppConfig = { }, proxy: { GIT_RAW_CONTENT: 'https://cdn-ide-raw.tonstudio.io', - GIT_IMPORT: 'https://cdn-ide-github.tonstudio.io', + GIT_IMPORT: 'https://cdn-ide-codeload.tonstudio.io', }, cors: { proxy: diff --git a/src/utility/gitRepoDownloader.ts b/src/utility/gitRepoDownloader.ts index 732664d4..d97ba1d7 100644 --- a/src/utility/gitRepoDownloader.ts +++ b/src/utility/gitRepoDownloader.ts @@ -36,7 +36,7 @@ async function convertToZipUrl( branchName = repoData.default_branch; } - const zipUrl = `${owner}/${repo}/archive/refs/heads/${branchName}.zip`; + const zipUrl = `${owner}/${repo}/zip/refs/heads/${branchName}`; return { url: zipUrl, path: pathName }; }