From 85c54ab3c6a5b3d084f19b8a4d4f812aaa923153 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:57:33 +0200 Subject: [PATCH] Integrate live CHOAM exchange browser and protected read-only API --- website/worker/runtime.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/worker/runtime.mjs b/website/worker/runtime.mjs index f781088d..4f1d6277 100644 --- a/website/worker/runtime.mjs +++ b/website/worker/runtime.mjs @@ -1,7 +1,8 @@ import {handleFeed} from './feed-api.mjs'; +import {handleExchange} from './exchange-api.mjs'; import {handleForum} from './forum-api.mjs'; import {handleCommunity} from './community-api.mjs'; import {handlePortal} from './portal-api.mjs'; // ASSET_DATA is injected by scripts/build.mjs. No credentials enter this bundle. const security={'X-Content-Type-Options':'nosniff','Referrer-Policy':'strict-origin-when-cross-origin','Content-Security-Policy':"default-src 'self'; img-src 'self' data:; style-src 'self' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; script-src 'self'; connect-src 'self'; frame-ancestors 'self' https://chatgpt.com https://*.chatgpt.com; base-uri 'self'; object-src 'none'"}; -export default {async fetch(request,env){const url=new URL(request.url);if(url.pathname==='/api/community')return handleCommunity(request);if(url.pathname==='/api/profile'||url.pathname.startsWith('/api/portal/')||url.pathname.startsWith('/api/tickets'))return handlePortal(request,env);if(url.pathname.startsWith('/api/forum'))return handleForum(request,env);if(url.pathname.startsWith('/api/'))return handleFeed(request,env);if(!['GET','HEAD'].includes(request.method))return new Response('Method not allowed',{status:405});let key;try{key=decodeURIComponent(url.pathname)}catch{return new Response('Bad request',{status:400})}if(key==='/')key='/index.html';const asset=ASSET_DATA[key];if(!asset)return new Response('Page not found',{status:404,headers:security});const [mime,b64]=asset;const data=request.method==='HEAD'?null:Uint8Array.from(atob(b64),c=>c.charCodeAt(0));return new Response(data,{headers:{...security,'Content-Type':mime,'Cache-Control':key.startsWith('/assets/')?'public, max-age=86400':'no-cache'}})}}; +export default {async fetch(request,env){const url=new URL(request.url);if(url.pathname.startsWith('/api/exchange/'))return handleExchange(request,env);if(url.pathname==='/api/community')return handleCommunity(request);if(url.pathname==='/api/profile'||url.pathname.startsWith('/api/portal/')||url.pathname.startsWith('/api/tickets'))return handlePortal(request,env);if(url.pathname.startsWith('/api/forum'))return handleForum(request,env);if(url.pathname.startsWith('/api/'))return handleFeed(request,env);if(!['GET','HEAD'].includes(request.method))return new Response('Method not allowed',{status:405});let key;try{key=decodeURIComponent(url.pathname)}catch{return new Response('Bad request',{status:400})}if(key==='/')key='/index.html';const asset=ASSET_DATA[key];if(!asset)return new Response('Page not found',{status:404,headers:security});const [mime,b64]=asset;const data=request.method==='HEAD'?null:Uint8Array.from(atob(b64),c=>c.charCodeAt(0));return new Response(data,{headers:{...security,'Content-Type':mime,'Cache-Control':key.startsWith('/assets/')?'public, max-age=86400':'no-cache'}})}};