Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: update proxy URLs to use TON Studio CDN #339

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false
NEXT_PUBLIC_DISABLE_WEBCONTAINER=false

# https://proxy.cors.sh/
NEXT_PUBLIC_PROXY_KEY=
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 4 additions & 14 deletions src/components/template/ProjectTemplate/ProjectTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/config/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/constant/projectExamples.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
5 changes: 2 additions & 3 deletions src/utility/gitRepoDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand All @@ -55,8 +55,7 @@ export async function downloadRepo(repoURL: string): Promise<Tree[]> {
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',
});

Expand Down