@@ -17,12 +17,9 @@ export interface Env {
1717
1818export default {
1919 async fetch ( request : Request , env : Env , ctx : ExecutionContext ) : Promise < Response > {
20- if ( ! env . REWRITE_HOSTNAME ) throw new Error ( "Missing REWRITE_HOSTNAME" ) ;
21- console . log ( "url" , request . url ) ;
22-
2320 if ( ! queueingIsEnabled ( env ) ) {
2421 console . log ( "Missing AWS credentials. Passing through to the origin." ) ;
25- return redirectToOrigin ( request , env ) ;
22+ return fetch ( request ) ;
2623 }
2724
2825 const url = new URL ( request . url ) ;
@@ -42,25 +39,10 @@ export default {
4239 }
4340
4441 //the same request but with the hostname (and port) changed
45- return redirectToOrigin ( request , env ) ;
42+ return fetch ( request ) ;
4643 } ,
4744} ;
4845
49- function redirectToOrigin ( request : Request , env : Env ) {
50- const newUrl = new URL ( request . url ) ;
51- newUrl . hostname = env . REWRITE_HOSTNAME ;
52- newUrl . port = env . REWRITE_PORT || newUrl . port ;
53-
54- const requestInit : RequestInit = {
55- method : request . method ,
56- headers : request . headers ,
57- body : request . body ,
58- } ;
59-
60- console . log ( "rewritten url" , newUrl . toString ( ) ) ;
61- return fetch ( newUrl . toString ( ) , requestInit ) ;
62- }
63-
6446function queueingIsEnabled ( env : Env ) {
6547 return (
6648 env . AWS_SQS_ACCESS_KEY_ID &&
0 commit comments