An API for my personal portfolio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix cors issue

+14 -5
+14 -5
src/index.ts
··· 11 11 app.use( 12 12 "*", 13 13 cors({ 14 - origin: [ 15 - "https://matthew-hre.com", 16 - "https://beta.matthew-hre.com", 17 - "http://localhost:3000", 18 - ], 14 + origin: (origin) => { 15 + const allowed = [ 16 + "https://matthew-hre.com", 17 + "https://beta.matthew-hre.com", 18 + "http://localhost:3000", 19 + ]; 20 + if (!origin) return null; 21 + if (allowed.includes(origin)) return origin; 22 + // allow Cloudflare Workers preview subdomains for matthew-hre.com 23 + if (/^https:\/\/[a-z0-9-]+\.matthew-hre\.workers\.dev$/.test(origin)) { 24 + return origin; 25 + } 26 + return null; 27 + }, 19 28 }) 20 29 ); 21 30