ClickHouse/website/workers/play-api.js

25 lines
572 B
JavaScript
Raw Normal View History

2020-03-14 20:01:50 +00:00
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let url = new URL(request.url);
url.hostname = 'play-api.clickhouse.tech';
url.port = 8443;
url.pathname = url.pathname.replace('/api/', '/');
let newHdrs = new Headers()
const init = {
body: request.body,
headers: request.headers,
method: request.method
}
let response = await fetch(url, init);
return new Response(response.body, {
status: response.status,
statusText: response.statusText
})
}