Skip to content

Instantly share code, notes, and snippets.

@surfaceflinger
Created October 15, 2022 22:07
Show Gist options
  • Save surfaceflinger/5657077fbd16336234b51ea34fcb07e6 to your computer and use it in GitHub Desktop.
Save surfaceflinger/5657077fbd16336234b51ea34fcb07e6 to your computer and use it in GitHub Desktop.
cloudflare worker -> oracle cloud object storage proxy
addEventListener('fetch', event => {
handleRequest(event);
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(event) {
var url = new URL(event.request.url);
if(url.pathname.endsWith('/')) {
var path = url.pathname + 'index.html';
} else {
var path = url.pathname;
}
var originUrl = 'https://objectstorage.{REGION}.oraclecloud.com/n/{NAMESPACE}/b/site/o' + path + url.search;
event.respondWith(fetch(originUrl));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment