Creating a CORS proxy server using testing/RunKit
Table of Contents
Problem
return (async (fn) => {
try {
const resp = await fetch("https://example.com");
console.log(resp.status);
return resp.text();
} catch (err) {
return err.message;
}
})();
Implementation
Testing & Usage
return (async (fn) => {
const endpoint = await lit.file.data.plugins.proxy.corsProxy(true);
return endpoint
})();
return (async (fn) => {
const fetch = await lit.file.data.plugins.proxy.corsProxy();
const resp = await fetch('https://example.com')
console.log(resp.status)
return resp.text();
})();
@startmindmap
* root node
* some first level node
* second level node
* another second level node
* another first level node
@endmindmap
<img src="/testing/repl-output.svg"/>
return lit.fs.readStat("/testing/repl-output.svg", "utf8");
return fetch('/testing/repl-output.svg')
.then(res => res.headers.get('server'))
return fetch('/testing/repl-output.svg')
.then(res => res.headers.get('Content-Type'))
return fetch('/testing/repl-output.svg')
.then(res => res.text())