Created
October 15, 2022 22:07
-
-
Save surfaceflinger/5657077fbd16336234b51ea34fcb07e6 to your computer and use it in GitHub Desktop.
cloudflare worker -> oracle cloud object storage proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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