33 lines
951 B
JavaScript
33 lines
951 B
JavaScript
/**
|
|
* ResumeGate - Cloudflare Worker
|
|
* Static files served from ./public via [assets] in wrangler.toml
|
|
* Worker handles CORS headers and /demo redirect only
|
|
*/
|
|
|
|
export default {
|
|
async fetch(request, env, ctx) {
|
|
const url = new URL(request.url);
|
|
|
|
// Handle CORS preflight for widget embeds
|
|
if (request.method === 'OPTIONS') {
|
|
return new Response(null, {
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
'Access-Control-Allow-Headers': 'Content-Type',
|
|
'Access-Control-Max-Age': '86400',
|
|
},
|
|
});
|
|
}
|
|
|
|
// Redirect /demo shortcut
|
|
if (url.pathname === '/demo') {
|
|
return Response.redirect(url.origin + '/widget-demo.html', 302);
|
|
}
|
|
|
|
// Pass through to assets — this is the fallback
|
|
// Assets binding handles static files automatically
|
|
return new Response('Not Found', { status: 404 });
|
|
},
|
|
};
|