Skip to content

Commit 1b4e52a

Browse files
Feat/fix path zrok (#9)
* feat: enhance performance and UI/UX - 【Performance】 - use web workers for sky projection calculations - implement LOD (level of detail) for sky map rendering - optimize data fetching with caching and timeouts - reduce bundle size with manual chunking - add performance monitor component - 【UI/UX】 - improve responsive design for filters drawer and map/table panels - add loading state for initial data loading - enhance sky map with zoom reset button - improve table with pagination and row selection - 【Refactor】 - refactor sky projection logic - memoize components and callbacks - use requestAnimationFrame for map drawing - 【Fix】 - fix table page size exceeding limit * docs: update dashboard link and image - replace streamlit dashboard gif with new dashboard gif - update dashboard link to cosmoobs github page * Update dashboard/src/components/PerformanceMonitor.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update dashboard/src/components/SkyMap.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update dashboard/src/components/SkyMap.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update dashboard/src/hooks/useDebounce.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * refactor: reverted sky projection with web worker - use inline worker script to avoid bundling issues - improve performance stats by removing async from measureRenderTime - fix DEC parallels calculation * feat: migrate from ngrok to zrok for tunneling - replace ngrok with zrok for improved tunneling - update minio endpoint url in notebooks and dashboard - add zrok interstitial bypass header for seamless access - implement dev proxy in vite config to inject headers and avoid cors issues - update cutout url construction for dev and production environments - remove ngrok-specific code and dependencies - update image loading logic to handle zrok redirects - update cutout card component to set alt attribute for accessibility --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent c6ef8c0 commit 1b4e52a

8 files changed

Lines changed: 45 additions & 62 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Tabular data and processed image cutouts are available for download.
4949
<img src=".figures/minio_service.gif" width="60%" alt="Animated GIF of data download from the MinIO service" />
5050
</p>
5151

52-
➡️ **[MinIO Service Link](https://ruggedly-quaky-maricruz.ngrok-free.app/login)**
52+
➡️ **[MinIO Service Link](https://3t611xfvhvp2.share.zrok.io)**
5353
**Instructions & Examples:**
5454
* Data access instructions: **[Data Access Notebook](./notebooks/how_to.ipynb)**.
5555
* Additional example notebooks (database exploration, proposal planning): `notebooks/` folder, including **[Proposal Planning Notebook](./notebooks/proposals/proposals.ipynb)**.

dashboard/src/api.ts

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,20 @@ export const loadCutouts = (): Promise<CutoutRecord[]> => fetchJson<CutoutRecord
8686
// - Else we prepend scheme from VITE_MINIO_SCHEME (default 'https').
8787
// - This allows using plain HTTP during local dev / tunnels without mixed content surprises.
8888
// const RAW_ENDPOINT: string | undefined = (import.meta as { env?: Record<string, string> }).env?.VITE_MINIO_ENDPOINT;
89-
const RAW_ENDPOINT: string | undefined = "nonarithmetically-undeliberating-janelle.ngrok-free.app";
89+
const RAW_ENDPOINT: string | undefined = "l5s5a0sibv6w.share.zrok.io";
9090
const ENDPOINT_SCHEME: string = ((import.meta as { env?: Record<string, string> }).env?.VITE_MINIO_SCHEME || 'https').replace(/:$/,'');
9191
export const buildCutoutUrl = (objectKey: string): string => {
9292
const cleaned = objectKey.trim().replace(/^\/+/, '');
93-
// Ensure Cutouts/ prefix once
9493
const path = cleaned.startsWith('Cutouts/') ? cleaned : `Cutouts/${cleaned}`;
94+
95+
// In dev, go through local proxy to inject headers and avoid CORS + interstitial
96+
if (import.meta.env && (import.meta as any).env.DEV) {
97+
// Strip the prefix "Cutouts/" because the proxy rewrite adds it back (see vite proxy config)
98+
const proxied = '/proxy-cutouts/' + path.replace(/^Cutouts\//, '');
99+
if((import.meta as { env?: Record<string, string> }).env?.VITE_DEBUG_CUTOUTS) console.debug('[cutout-url-dev-proxy]', { objectKey, path, proxied });
100+
return proxied;
101+
}
102+
95103
if(!RAW_ENDPOINT) return path; // fallback relative path if not configured
96104
let base = RAW_ENDPOINT.trim();
97105
if(!/^https?:\/\//i.test(base)) {
@@ -106,54 +114,10 @@ export const buildCutoutUrl = (objectKey: string): string => {
106114
// Simple async wrapper (keeps existing calling pattern with react-query)
107115
export const getCutoutObject = async (objectKey: string): Promise<string | null> => {
108116
const url = buildCutoutUrl(objectKey);
109-
110-
// For ngrok URLs, we need to add headers to bypass the browser warning
111-
if (RAW_ENDPOINT && RAW_ENDPOINT.includes('ngrok')) {
112-
try {
113-
console.log('[DEBUG] Fetching image with ngrok headers:', url);
114-
115-
// Create a new URL object to add ngrok bypass headers
116-
const response = await fetch(url, {
117-
method: 'GET',
118-
headers: {
119-
'ngrok-skip-browser-warning': 'true',
120-
'User-Agent': 'LaStBeRu-Explorer/1.0 (Custom)'
121-
},
122-
mode: 'cors',
123-
credentials: 'omit'
124-
});
125-
126-
console.log('[DEBUG] Response status:', response.status, response.statusText);
127-
128-
if (response.ok) {
129-
// Convert to blob URL for better browser handling
130-
const blob = await response.blob();
131-
const blobUrl = URL.createObjectURL(blob);
132-
console.log('[DEBUG] Created blob URL:', blobUrl);
133-
return blobUrl;
134-
} else {
135-
console.warn('[DEBUG] Response not ok:', response.status, response.statusText);
136-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
137-
}
138-
} catch (error) {
139-
console.warn('Failed to fetch image with headers:', error);
140-
// Try creating an image element that can handle the ngrok redirect
141-
return new Promise((resolve) => {
142-
const img = new Image();
143-
img.crossOrigin = 'anonymous';
144-
img.onload = () => {
145-
console.log('[DEBUG] Image loaded successfully via img element');
146-
resolve(url);
147-
};
148-
img.onerror = () => {
149-
console.warn('[DEBUG] Image failed to load via img element');
150-
resolve(url); // Still return URL, let the component handle the error
151-
};
152-
img.src = url;
153-
});
154-
}
117+
// In dev with proxy we just return the proxied path; browser will request via Vite server
118+
if ((import.meta as any).env?.DEV) {
119+
return url;
155120
}
156-
157-
console.log('[DEBUG] Using direct URL:', url);
121+
// In production (no proxy) just return direct URL (CORS must be handled server-side)
158122
return url;
159123
};

dashboard/src/components/CutoutGrid.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const CutoutCard: React.FC<{ record: CutoutRecord }> = memo(({ record }) => {
4444
src={data}
4545
loading="lazy"
4646
decoding="async"
47-
crossOrigin="anonymous"
47+
alt={record.band + ' cutout'}
4848
style={{ position:'absolute', inset:0, width:'100%', height:'100%', objectFit:'contain', imageRendering:'auto' }}
4949
onError={(e)=>{
5050
const img = e.currentTarget;
@@ -54,7 +54,7 @@ const CutoutCard: React.FC<{ record: CutoutRecord }> = memo(({ record }) => {
5454
// For ngrok URLs, try adding the bypass parameters as query string
5555
if (img.src.includes('ngrok')) {
5656
const url = new URL(img.src);
57-
url.searchParams.set('ngrok-skip-browser-warning', 'true');
57+
url.searchParams.set('skip_zrok_interstitial', 'true');
5858
img.src = url.toString();
5959
return;
6060
}

dashboard/vite.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,29 @@ export default defineConfig({
4646
server: {
4747
port: 5173,
4848
headers: {
49-
// Add headers to help with CORS during development
49+
// Basic permissive headers (still need target server cooperation for true CORS)
5050
'Access-Control-Allow-Origin': '*',
5151
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
5252
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
53+
},
54+
// Dev-only proxy to inject the zrok interstitial bypass header and avoid CORS issues.
55+
proxy: {
56+
// Usage in code: fetch('/proxy-cutouts/<rest-of-cutouts-path>')
57+
'/proxy-cutouts': {
58+
target: 'https://l5s5a0sibv6w.share.zrok.io',
59+
changeOrigin: true,
60+
// Rewrite /proxy-cutouts/Processed_Cutouts/... -> /slcomp/Cutouts/Processed_Cutouts/...
61+
rewrite: (path) => path
62+
.replace(/^\/proxy-cutouts\/?/, '/slcomp/Cutouts/')
63+
.replace(/\/+/g,'/'),
64+
configure: (proxy) => {
65+
proxy.on('proxyReq', (proxyReq) => {
66+
// Header required by zrok to skip warning interstitial
67+
proxyReq.setHeader('skip_zrok_interstitial', 'true');
68+
proxyReq.setHeader('User-Agent', 'LaStBeRu-Explorer/1.0 (DevProxy)');
69+
});
70+
}
71+
}
5372
}
5473
}
5574
});

notebooks/footprints/footprints.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
")\n",
5252
"\n",
5353
"\n",
54-
"MINIO_ENDPOINT_URL = \"nonarithmetically-undeliberating-janelle.ngrok-free.app\"\n",
54+
"MINIO_ENDPOINT_URL = \"l5s5a0sibv6w.share.zrok.io\"\n",
5555
"ACCESS_KEY = \"slcomp\"\n",
5656
"SECRET_KEY = \"slcomp@data\"\n",
5757
"client = Minio(\n",

notebooks/how_to.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"metadata": {},
6262
"outputs": [],
6363
"source": [
64-
"MINIO_ENDPOINT_URL = \"nonarithmetically-undeliberating-janelle.ngrok-free.app\"\n",
64+
"MINIO_ENDPOINT_URL = \"l5s5a0sibv6w.share.zrok.io\n",
6565
"ACCESS_KEY = \"slcomp\"\n",
6666
"SECRET_KEY = \"slcomp@data\"\n",
6767
"client = Minio(\n",
@@ -74,7 +74,7 @@
7474
},
7575
{
7676
"cell_type": "code",
77-
"execution_count": 3,
77+
"execution_count": 9,
7878
"id": "994a76e5-b83e-4e47-94b0-86b8636c5821",
7979
"metadata": {},
8080
"outputs": [
@@ -84,7 +84,7 @@
8484
"[Bucket('slcomp')]"
8585
]
8686
},
87-
"execution_count": 3,
87+
"execution_count": 9,
8888
"metadata": {},
8989
"output_type": "execute_result"
9090
}
@@ -3023,7 +3023,7 @@
30233023
],
30243024
"metadata": {
30253025
"kernelspec": {
3026-
"display_name": "Python 3 (ipykernel)",
3026+
"display_name": "base",
30273027
"language": "python",
30283028
"name": "python3"
30293029
},
@@ -3037,7 +3037,7 @@
30373037
"name": "python",
30383038
"nbconvert_exporter": "python",
30393039
"pygments_lexer": "ipython3",
3040-
"version": "3.12.7"
3040+
"version": "3.12.11"
30413041
}
30423042
},
30433043
"nbformat": 4,

notebooks/modified-gravity-tests/01_LaStBeRu_cosmo_ground.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"source": [
8383
"from minio import Minio\n",
8484
"\n",
85-
"MINIO_ENDPOINT_URL = \"nonarithmetically-undeliberating-janelle.ngrok-free.app\"\n",
85+
"MINIO_ENDPOINT_URL = \"l5s5a0sibv6w.share.zrok.io\"\n",
8686
"ACCESS_KEY = \"slcomp\"\n",
8787
"SECRET_KEY = \"slcomp@data\"\n",
8888
"client = Minio(\n",

notebooks/proposals/proposals.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
" }\n",
3636
")\n",
3737
"\n",
38-
"MINIO_ENDPOINT_URL = \"nonarithmetically-undeliberating-janelle.ngrok-free.app\"\n",
38+
"MINIO_ENDPOINT_URL = \"l5s5a0sibv6w.share.zrok.io\"\n",
3939
"ACCESS_KEY = \"slcomp\"\n",
4040
"SECRET_KEY = \"slcomp@data\"\n",
4141
"client = Minio(\n",

0 commit comments

Comments
 (0)