mirror of
https://github.com/torappinfo/uweb.git
synced 2026-03-14 22:55:45 +01:00
18 lines
461 B
JavaScript
18 lines
461 B
JavaScript
export async function onRequest(context) {
|
|
const { request, env } = context;
|
|
let url = request.url;
|
|
let iSlash = url.indexOf('?',11);
|
|
let nUrl = url.substring(iSlash+1);
|
|
return await goUrl(request, nUrl);
|
|
}
|
|
|
|
async function goUrl(request, url) {
|
|
const Url = new URL(url);
|
|
const newReq = new Request(Url, {
|
|
method: request.method,
|
|
headers: request.headers,
|
|
body: request.body,
|
|
redirect: 'follow'
|
|
})
|
|
return await fetch(newReq);
|
|
}
|