You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportdefault{asyncfetch(request,env,ctx){leturl=newURL(request.url);// Modify the hostname based on the pathif(url.pathname.startsWith('/translate_a/')||url.pathname.startsWith('/translate_tts')||url.pathname.startsWith('/translate')){url.hostname="translate.googleapis.com";}else{url.hostname="translate.google.com";}// Create a new request with the modified URL and original request optionsletnew_request=newRequest(url.toString(),{method: request.method,headers: request.headers,body: request.body,redirect: 'follow'});// Fetch the modified requestletresponse=awaitfetch(new_request);// Create a new response to handle contentletnew_response=newResponse(response.body,response);// Add CORS headers if necessarynew_response.headers.set("Access-Control-Allow-Origin","*");new_response.headers.set("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS");new_response.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization");returnnew_response;}};